Need a Unique ID for a Microsoft Dynamics CRM 2011 Entity?
Increasing Out of the Box capabilities of CRM 2011 in a creative way!
I am currently working in a Project where our customer requires a Unique ID to be added to each Opportunity created in 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 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 duplicated numbers. In 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 Cases, Quotes, Orders, Invoices, etc…Wait a second – Maybe we can! – Can we?
Well, sort of…an Idea came to my head; I created a Workflow that upon Opportunity Creation it would create an Order (IDs begin with ORD so it’s close to Opportunities but any of the entities named above would work), 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:
Create an Opportunity ID (text) field and place it somewhere in the form – I chose the Header for extra visibility:
OPTIONAL: Edit the “Statuscode” of Orders to Specify why the Order was Deactivated:
Create a Workflow to launch upon Opportunity Creation to Create an Order, Copy the ID and then Deactivate the Order:
Here are the details of this workflow:
On Step 1, create a base Order:
On Step 2, Update the Opportunity ID with the Order ID of the Order you just created on Step 1:
On Step 3, deactivate the Order created on Step 1:
- Activate the Workflow.
As Opportunities are created in 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 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:
- In CRM 2011, navigate to Settings -> Data Management -> Bulk Record Deletion
Create a new Bulk Delete Operation that searches for Orders created by the workflow (This operation will run daily for our customer because of the high number of records created daily but it could be scheduled to run weekly or Bi-Weekly):