How to Concat Text field and AutoIncrement number

I'm wanting to create a new text field that is the concatenation of an alphabetic code field and an AutoIncrement numeric field.  I don't see the AutoIncrement field in the choices when setting the calculation of the text field in Studio:

concat($alpha_code,??????)

How is this done?

Parents
  • Hi ,

    Stock autoincrement fields like the ones found in the Cases and Quotes module can be used in the formula as you are seeking. I tested creating an autoincrement field in another module and observed the same issue as you. The field is not in the listing of available fields for Sugar Logic calculations. When I tried to create a formula by manually entering the field name, the formula would not save with the reason that the field was unknown. 

    Comparing the definition of the stock autoincrement fields to custom fields highlighted a key difference. Here is how the case_number field is defined:

        'case_number' => 
        array (
          'name' => 'case_number',
          'vname' => 'LBL_NUMBER',
          'type' => 'int',
          'readonly' => true,
          'len' => 11,
          'required' => true,
          'auto_increment' => true,
          'unified_search' => true,
          'full_text_search' => 
          array (
            'enabled' => true,
            'searchable' => true,
            'boost' => 1.29,
          ),
          'comment' => 'Visual unique identifier',
          'duplicate_merge' => 'disabled',
          'disable_num_format' => true,
          'studio' => 
          array (
            'quickcreate' => false,
          ),
          'duplicate_on_record_copy' => 'no',
        ),

    Versus how a custom autoincrement field created in Studio is defined:

        'test_autoinc_c' => 
        array (
          'labelValue' => 'Test AutoInc',
          'full_text_search' => 
          array (
            'enabled' => '0',
            'boost' => '1',
            'searchable' => false,
          ),
          'dependency' => '',
          'auto_increment' => 'true',
          'required' => false,
          'readonly' => true,
          'source' => 'custom_fields',
          'name' => 'test_autoinc_c',
          'vname' => 'LBL_TEST_AUTOINC',
          'type' => 'autoincrement',
          'massupdate' => false,
          'hidemassupdate' => false,
          'no_default' => false,
          'comments' => '',
          'help' => '',
          'importable' => false,
          'duplicate_merge' => 'enabled',
          'duplicate_merge_dom_value' => 1,
          'audited' => false,
          'reportable' => true,
          'unified_search' => false,
          'merge_filter' => 'disabled',
          'pii' => false,
          'calculated' => false,
          'len' => 11,
          'size' => '20',
          'enable_range_search' => false,
          'dbType' => 'int',
          'disable_num_format' => true,
          'auto_increment_platform_options' => 
          array (
            'unique' => true,
          ),
          'min' => 1,
          'max' => NULL,
          'validation' => 
          array (
            'type' => 'range',
            'min' => 1,
            'max' => NULL,
          ),
          'autoinc_next' => '2',
          'id' => 'a23169b2-f5e9-11ed-8471-02d60046d9de',
          'custom_module' => 'Tasks',
        ),

    The difference is the field type (int vs autoincrement). I assume the custom fields have this type as some safeguard to ensure only one custom autoincrement field can be created per module due to database restrictions. Once a field of 'autoincrement' type is created, it no longer appears as an available field type in that module. With that said, it seems like an oversight that this field type cannot be used in features like Sugar Logic.

    There is a known defect (86477) filed for this issue. I recommend filing a support case to let Sugar know you are impacted by this issue too. 

    I did find a way to get the field available in Sugar Logic and Sugar Support may be willing to make the change for you. I edited the following file generated for the custom autoincrement field:

    ./custom/Extension/modules/{module_name}/Ext/Vardefs/sugarfield_{field_name}.php

    In that file, I added the following line:

    $dictionary['{singular_module_name}']['fields']['{field_name}']['type'] = 'int';

    I then performed a quick repair and confirmed the field was available to use in Sugar Logic. The downside of this workaround is that the 'AutoIncrement' field type becomes available for that module again in Studio and would likely cause an error if you tried to create a second autoincrement field in the module. 

    One additional note is that Sugar Logic involving autoincrement fields will not trigger on the initial save of the record. This is because Sugar does not know what the incremental number will be (the incremental value is created by the database after the record is saved in Sugar). This means if you want the formula to work for newly created records, you will need to create SugarBPM definition to trigger on newly created records and re-save them in order for the formula to trigger as you expect. 

    I hope this helps!

    Chris

Reply
  • Hi ,

    Stock autoincrement fields like the ones found in the Cases and Quotes module can be used in the formula as you are seeking. I tested creating an autoincrement field in another module and observed the same issue as you. The field is not in the listing of available fields for Sugar Logic calculations. When I tried to create a formula by manually entering the field name, the formula would not save with the reason that the field was unknown. 

    Comparing the definition of the stock autoincrement fields to custom fields highlighted a key difference. Here is how the case_number field is defined:

        'case_number' => 
        array (
          'name' => 'case_number',
          'vname' => 'LBL_NUMBER',
          'type' => 'int',
          'readonly' => true,
          'len' => 11,
          'required' => true,
          'auto_increment' => true,
          'unified_search' => true,
          'full_text_search' => 
          array (
            'enabled' => true,
            'searchable' => true,
            'boost' => 1.29,
          ),
          'comment' => 'Visual unique identifier',
          'duplicate_merge' => 'disabled',
          'disable_num_format' => true,
          'studio' => 
          array (
            'quickcreate' => false,
          ),
          'duplicate_on_record_copy' => 'no',
        ),

    Versus how a custom autoincrement field created in Studio is defined:

        'test_autoinc_c' => 
        array (
          'labelValue' => 'Test AutoInc',
          'full_text_search' => 
          array (
            'enabled' => '0',
            'boost' => '1',
            'searchable' => false,
          ),
          'dependency' => '',
          'auto_increment' => 'true',
          'required' => false,
          'readonly' => true,
          'source' => 'custom_fields',
          'name' => 'test_autoinc_c',
          'vname' => 'LBL_TEST_AUTOINC',
          'type' => 'autoincrement',
          'massupdate' => false,
          'hidemassupdate' => false,
          'no_default' => false,
          'comments' => '',
          'help' => '',
          'importable' => false,
          'duplicate_merge' => 'enabled',
          'duplicate_merge_dom_value' => 1,
          'audited' => false,
          'reportable' => true,
          'unified_search' => false,
          'merge_filter' => 'disabled',
          'pii' => false,
          'calculated' => false,
          'len' => 11,
          'size' => '20',
          'enable_range_search' => false,
          'dbType' => 'int',
          'disable_num_format' => true,
          'auto_increment_platform_options' => 
          array (
            'unique' => true,
          ),
          'min' => 1,
          'max' => NULL,
          'validation' => 
          array (
            'type' => 'range',
            'min' => 1,
            'max' => NULL,
          ),
          'autoinc_next' => '2',
          'id' => 'a23169b2-f5e9-11ed-8471-02d60046d9de',
          'custom_module' => 'Tasks',
        ),

    The difference is the field type (int vs autoincrement). I assume the custom fields have this type as some safeguard to ensure only one custom autoincrement field can be created per module due to database restrictions. Once a field of 'autoincrement' type is created, it no longer appears as an available field type in that module. With that said, it seems like an oversight that this field type cannot be used in features like Sugar Logic.

    There is a known defect (86477) filed for this issue. I recommend filing a support case to let Sugar know you are impacted by this issue too. 

    I did find a way to get the field available in Sugar Logic and Sugar Support may be willing to make the change for you. I edited the following file generated for the custom autoincrement field:

    ./custom/Extension/modules/{module_name}/Ext/Vardefs/sugarfield_{field_name}.php

    In that file, I added the following line:

    $dictionary['{singular_module_name}']['fields']['{field_name}']['type'] = 'int';

    I then performed a quick repair and confirmed the field was available to use in Sugar Logic. The downside of this workaround is that the 'AutoIncrement' field type becomes available for that module again in Studio and would likely cause an error if you tried to create a second autoincrement field in the module. 

    One additional note is that Sugar Logic involving autoincrement fields will not trigger on the initial save of the record. This is because Sugar does not know what the incremental number will be (the incremental value is created by the database after the record is saved in Sugar). This means if you want the formula to work for newly created records, you will need to create SugarBPM definition to trigger on newly created records and re-save them in order for the formula to trigger as you expect. 

    I hope this helps!

    Chris

Children