How to add a Autoincrement [Unique Id] field for Accounts and Meetings Modules etc

I used this code .Its worked only my database.Its added a new field [autoincrement_id] in my account table in my db.But it does not show in listview and Detailview. I want show this fields in listview and Detailview

custom/Extension/modules/yourmodule/Ext/Vardefs/
autoincrement.php

<?php
            $dictionary['Account']['fields']['autoincrement_id']['auto_increment'] = true; 
?>

<?php
         $dictionary['Account']['fields']['autoincrement_id'] =  array(
               'name' => 'autoincrement_id',
            'vname' => 'LBL_LABEL_OF_AUTO_INC_FIELD',
            'type' => 'int',
            'readonly' => true,
            'len' => 11,
              'auto_increment' => true,
           'disable_num_format' => true,
        );
?>
<?php
         $dictionary['Account']['indices']['NAME_FOR_INDEX'] = array(
           'name' => 'NAME_FOR_INDEX',
            'type' => 'unique',
            'fields' => array('autoincrement_id'),
        );
?>
2 Likes

Hi,

If you’ve added the code above, and run a Quick Repair & Rebuild in the Admin->Repair section, you should be able to see the field in Studio

II don’t imagine it would add the field to any views by itself, so you may have to add them manually

So, if you go to Admin->Studio
Select “Accounts”, (or whichever module you have added the field to)
Select “Layouts”
Then, either “Detailview” or “Listview”

You should be able to drag in the new auto-increment field from the left, into the list of fields displayed on the right.

Then, once added, “Save & Deploy”

Are you able to see your field on the Listview/Detailview if you do the above?

2 Likes

Thank you John…It is done

Great, glad to hear it! :slight_smile:

I’m considering a plugin to do this. The plugin says it also allows to append - Add Prefixes and Suffixes to classify records: - Have you also tried this with code???