A common requirement in CRM implementations is the need to have readable identification numbers auto-generated for custom attributes. There are various ways of achieving this. This article provides a few options to do that.
Let’s use one scenario as a context. Let’s say we are building a Grants Management application and we are tracking scholarship applications in Dynamics CRM. We have an application entity which contains an Application Id field. For business reasons, we need to have a unique identifier to refer to the applications. What are out options? For starters, let’s look at some of the elements to consider when looking for an auto-numbering solution in Dynamics CRM?
- Are you using an entity that is auto-number enabled? (e.g. Case, Quotes, Orders etc.)
- Do you need the numbers to be sequential?
- Do you have potential race conditions? (i.e. can the event assigning the auto-number be triggered by multiple processes simultaneously?)
- Do the auto-numbers need to be human readable?
- What is the format required? (numeric only, alpha-numeric, letters only, prefix, suffix etc.)
- Can you and/or do you want to write code to generate these numbers or do you want an simple configurable solution?
Generate an unique number based on the current Date Time
Of course, this required a plugin on an event that will generate the application Id. From a technical standpoint, there are a few algorithms out there that will give you an indication as to how this can be done. The full date time and the “tick” should be use to generate the number to ensure uniqueness. But even with that, there is a very very very small chance of having race conditions depending on your application and on your (bad) luck. Also, this will not allow your to use sequential numbers.
Create a record of an auto-numbering CRM entity
If you are *not* using one of the CRM auto-numbering enabled entities (for example, Campaign), this solution is have a plugin (or a Workflow) on your triggering event that will create a Campaign record. This campaign will automatically be assigned a unique number based on your CRM configuration (image below). You can re-use that number as the unique ID for your record and delete the Campaign record that was created. While this is a simple method that can be implemented without coding, the numbers are not really sequential, “garbage” records are created at a cost (create/delete transactions time, what happens if you want/need to use that entity in the future?..). To be honest, it feels like a quick-and-dirty way of doing things, but it works.
The advantage here is that because the auto-numbers are platform generated, so you do not have to worry about race conditions in theory.
Use a model based on CRM Synchronous Workflow + Custom Auto-Number entity
I will not go too much into details about this one. There are lots of articles on the topic. A few “how-to” articles for reference:
- Auto-Numbering Solution for CRM 2013 Online from The MS CRM World Blog
- The Power of Synchronous Workflows For Autonumbering on Shan McArthur’s Blog
- Jukka’s “Auto-Numbering with CRM Workflows: Real-Time vs Asynchonous” article
- Eran Fuks’s LinkedIn article “Custom Auto-Numbering in 6 quick steps“
Bottom line, this is a great solution if you cannot write any code and don’t want to spend any money for something that should be standard in the platform (yes, I’m ranting, can’t help it). That being said, it you have race conditions, I’m sure you can have a few duplicated numbers with this solution.
Using a 3rd Party Tool
There are plenty of options out there. Some are more flexible than others. Some explicitly guarantee uniqueness, some don’t really mention it. Some are free, some are not.
- CRM Innovation’s AutoNumber Solution
- IOTAP’s Advanced Auto-Number for Dynamics CRM
- Open Source (free) : CRM 2015 / 2016 Autonunmber, Celedon Autonumber Solution for Dynamics CRM
- Formula Manager form North 52
These are just a few, a research will allow you find more of these and decide the one that fits your needs the best.
Build your own solution
At this point, you can do it anyway you want.
- If you have access to an external database, a CRM plugin that create a record in the database with an identity column will guarantee to always have unique and sequential numbers. This comes at a cost obviously (external database dependency, speed)
- There is also a smart way of doing robust auto-numbering suggested by Ken Heiman of Green Beacon here. Good read, smart idea.
- Some enterprises already have Auto-Numbering web services, you can simply consume that web service from a CRM plugin as well (same cost as database, dependency, speed)
- I have also seen the idea of using the Guid as a unique identifier, by copying the value into a text field with a plugin. I don’t think it’s readable, but definitely unique.
It had been too long. Happy CRM’ing !