Editor's Note: The following MVP Monday post is by Dynamics CRM MVP Gus Gonzales
Generating Unique IDs for any Microsoft Dynamics CRM 2011 Entity
Increasing Out of the Box capabilities of CRM 2011 in a creative way!
I was working on a Project where our customer required a Unique ID to be added to each Opportunity created in Microsoft Dynamics CRM 2011. Opportunities will be created manually sometimes but mostly via data imports so this process had to be accurate as these records will be imported in the thousands and handled by multiple departments and users within our customers company.
I started researching for a solution online for this issue but I couldn't find a single reliable solution that could satisfy the assignment of Unique IDs to thousands of Opportunities created by CSV Import on Microsoft Dynamics CRM 2011 Online.
We started thinking about creating a custom Plug in that would address this issue for our customer but we had some concerns regarding the fact that we were not allowed to lock the server during the operation, so we could not prevent duplicate numbers. With Microsoft Dynamics CRM 2011 On-Prem, we lock the server from the time we query for "what was the last used number" until the time we commit the save so you can make sure that numbers are not repeated.
If only we had access to the awesome Plug In that the Microsoft Dynamics CRM 2011 Team created to Uniquely Identify Contracts, Cases, Articles, Quotes, Orders, Invoices and Campigns…Wait a second - Maybe we can! - Can we?
Yes; well, sort of. An Idea came to my head; I created a Workflow that upon Opportunity Creation it would create an Order (Currently not being used by Microsoft Dynamics CRM 2011 Users), Copy the Order ID to an Opportunity ID field and then Deactivate the created Order.
This solution would provide a Unique ID to the Opportunities seconds after they have been created…for free!
Here are the steps taken to deploy this solution:
Here are the details of this workflow:
As Opportunities are created in Microsoft Dynamics CRM 2011, the Workflow will fire up and add the "Opportunity ID" to each Opportunity:
This quick, easy and FREE solution can be applied to any Entity in Microsoft Dynamics CRM 2011 that does not have the Unique ID capabilities Out of the Box.
As an OPTIONAL step, create a Bulk Deletion Job to run periodically to remove the Inactive Orders that were used as Unique ID generators. Here are the steps for that process:
NOTE: If your Microsoft Dynamics CRM 2011 Users are utilizing the Order entity, you could adapt the steps above to use any of the entities that have access to Unique IDs.
You can also modify the Prefix of the IDs by navigating to Settings -> Administration -> Auto-Numbering in Microsoft Dynamics CRM 2011 specifying the desired prefix for your company:
About the author
Gus Gonzalez is a Microsoft Dynamics CRM MVP and the SMB Team Lead and Solution Architect at Zero2Ten, Inc. He has over 10 years of consulting experience in the IT Industry, designing and implementing Microsoft Solutions ranging from enterprise to small environments. Worked as a full time Microsoft Certified Trainer from 2005 to 2009 teaching Microsoft Official Curriculum classes regarding Microsoft Windows, Exchange, ISA and SMS Servers along with Citrix, Cisco, EC-Council and CompTIA official curriculum. A Microsoft Dynamics CRM Community Guest Columnist passionate about User Adoption, he often talks about how Brazilian Jiu-Jitsu can be used to Increase User Adoption, sport he practices since January 2010. To learn more about Gus Gonzalez, read his blog or connect via LinkedIn and Twitter.
About MVP Monday
The MVP Monday Series is created by Melissa Travers. In this series we work to provide readers with a guest post from an MVP every Monday. Melissa is a Community Program Manager, formerly known as MVP Lead, for Messaging and Collaboration (Exchange, Lync, Office 365 and SharePoint) and Microsoft Dynamics in the US. She began her career at Microsoft as an Exchange Support Engineer and has been working with the technical community in some capacity for almost a decade. In her spare time she enjoys going to the gym, shopping for handbags, watching period and fantasy dramas, and spending time with her children and miniature Dachshund. Melissa lives in North Carolina and works out of the Microsoft Charlotte office.
Simple & clean use of available architecture. Nice job.
As maintaining unique id is anyway handled by internal code (CRM internal plug-ins), I think, we should also be able to initiate this using our plug-ins to make it synchronous (if ID generation is required to be synchronous).
This seems to solve that issue but does it not prevent that business unit from utilizing the Order piece of CRM and how it can link with Accounts and Opportunities in its original intent? If they did begin using Orders and linking them to Opportunities in a N:1 fashion I could see the owner of the opportunity becoming confused on the fact that the unique identifier for Opportunities and Orders are the same format.
But if you foresee that they will not implement the Order feature to its potential then this is a good solution.
Hello Every one,
Can you please help me to solve issue like generate auto-increment unique id on case form like Case ID?
Great solution! But halfway into building the workflow I realized that I needed a random number generator for Leads. Can you think of a work around since Leads are technically not customers so I was unable to create an order without a contact or account.