A number of times we come across a requirement to create a auto-incremental number for a variety of records in Dynamics CRM. The usual solution for this scenario has been developing a synchronous plug-in to generate an auto-incremental number and then assign to the record. Any solution involving developmental work has been costly to the customer and been subject of heavy testing activities because of risk involved with custom code.
Using CRM 2013 Synchronous workflows, auto-incremental numbers can be achieved without writing a single line of code. Some of custom auto-incremental solutions uses SQL table’s IDENTITY Columns or SQL 2012’s SEQUENCE feature and makes the solution difficult to deploy in a Dynamics CRM 2013 Online deployment.
Here I would discuss a solution which is completely native to Dynamics CRM and hence easy to deploy in CRM 2013 Online deployments. Follow the below steps to create an auto numbering solution for any entity, for example a CONTACT ID.
Step 1: Create an entity “Auto Number Definition”.
Step 2: Create the following fields for Auto Number Definition entity.
Step 3: Create another entity “Auto Number Request”.
Step 4: Create the following fields for Auto Number Request entity.
The idea here is to create an Auto Number Request record with every Contact record creation and Auto Number Request will generate a New Number using an Auto Number Definition record. The New Number would then be copied to the Contact record.
Step 5: Create a synchronous workflow on Auto Number Request entity.
Step 6: Create a Auto Number Definition Record for the contact entity.
Step 7: Create another synchronous workflow on Contact entity.