The views and opinions expressed in this blog are those solely of the author(s) and do not necessarily reflect Microsoft’s current policy, position, or branding. For official announcements and guidance on Dynamics 365 apps and services, please visit the Microsoft Dynamics 365 Blog.
Personalized Community is here!
Quickly customize your community to find the content you seek.
‘Better Together’ Integration forum available
We're launching a how-to forum where you can learn and engage about how Dynamics 365 integrates with other Power Platform products.
Read about Better Together forum
2020 Release Wave 2Discover the latest updates and new features to Dynamics 365 planned through March 2021.
Release overview guides and videos Release Plan | Preview 2020 Release Wave 2 TimelineWatch the 2020 Release Wave 1 virtual launch event
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Upcoming TechTalks
A common request for Auto Numbers in Microsoft Dynamics 365 (CDS/CRM) is to have one number field with different formats and unique sequences based on data on the record or it’s parents.I call this “Conditional Unique Auto Number Sequences”.
In a previous article I demonstrated one way of including dynamic information in a numbered attribute using a calculated field for the number. In this one I will take another approach, and also add the unique sequences.
On my Rocket entity I have an OptionSet defining the Purpose of the rocket.
The customer required (I know what you all think but my customer is not Elon, he made me promise to always deny that) a separate sequence for each Purpose, but they should all be shown in the same field.As we know, this is not possible out of the box, so we have to bend the laws of nature a bit and come up with a little customization trick to satisfy him the customer.
First create a “generic numbering entity” that can be used for all numbering purposes in the system, where we need to up the game from OOB functionality.
Add fields for all different numbering sequences you need. In this case I have one sequence for Contacts, and four different for my Rockets, where the number sequence and format will depend on the chosen Purpose of the rocket.
The numbering fields can be configured something like below.Click the image to see full configuration.
Now create a real-time workflow triggering on create of the entity to be numbered, Rocket in my case.
Check the Purpose field of the created rocket, and for each of the available options, create a branch in the workflow. In each branch, add a step to create a new record of the Cool Numbers entity.
Set the name of the new record to indicate the source record (the new rocket) that triggered the creation of the numbering record. Then add a dash (-) to each of the auto number fields that will not be used for this condition. Leave the field for the selected number empty.
Adding the dashes will prevent these fields from being numbered, and thus “preserves” the numbers in their respective sequences.
Now add a step to update the rocket record that triggered the workflow. Set the Rocket Number field to the selected numbering field on the created numbering record.
Repeat this for all possible purposes.
The complete workflow will now look like this.
Creating new rockets in my environment, and they are now numbered according to my new unique sequences based on the selected purpose of each rocket.
To create conditional unique auto number sequences for one single field, follow these simple steps>
Now that you have implemented this type of smart conditional numbering, you might be wondering what you should do with all existing records?
There is a solution to that as well. Just go back to a previous article in this series – Auto Numbering existing records in Microsoft Dynamics 365 / CRM.
Well this article didn’t really solve Mirko’s request on Facebook. But stay tuned for next article, I will show you how to use this technique to only assign numbers when specific conditions are met.
The post Conditional Unique Auto Number Sequences in Microsoft Dynamics 365 / CRM appeared first on The Dynamics 365 Trenches.
Business Applications communities