| 07 February 2009
Incremental Numbering of SugarCRM Entities
One of the most common requests for any system is for a numerical counter for every entity. An invoice number is always required in a sales order system which should use an automated incremental counter. A small issue with SugarCRM is that there is not an incremental field option. A simple way around this is to create a custom field within a module. I needed a counter within the Opportunity module. SugarCRM makes it very easy to add this to the edit, detail and list views using the Studio. However, as I do not want this field to be updateable so I left it out of the editview. To create a systems generated incremental field I fired up phpadmin and edited this column. You will find that SugarCRM creates a custom table, in this case opportunities_cstm. MySQL insists that the new column is used in a key before it will permit the 'Auto Increment' column property to be set, so create a new index based on the new column and then set the auto increment property. You should then find that on the creation of a new Opportunity this field is set to the next sequential numeric value. A simple fix to a commonly requested enhancement with no code changes.


