In Dynamics 365 we are using number sequences to automatically create identifiers like product number, customer number etc. I’m a fan of having these numbers as “clean” as possible, and I always try to convince my customers use pure numbers. Why ? Take a look at the keyboard:
The numb-pad is the fastest way of typing in data. I also see that users normally perform lookup and see the description of what they are selecting anyway.
But let take a scenario; We will use a number sequence to create products numbers. We will then typical get product numbers like this :
Then I have often seen that another problem arises; typing errors from the num-pad are actually getting a “hit”, because when using a number sequence we can almost always find a product that have the same number as the user wrongly typed.
If you try using your credit card online you will see that the number is not accepted if any number is wrong. The solution there is to build in check-digits in the number.
I created a very small extension to solve this in Dynamics 365, with just a few lines of code. In the following example The “green” part is from the number sequence, and the yellow part is from the modulo 10 check digit calculation.
In this way the user can never type the wrong product(or any other identifier), unless it is 100% correct.
In the screen for number sequences I added an option to add the check digit to my generated numbers.
I wanted to share this with you, because it is so simple:
1. Create an extension on the table “NumberSequencetable”. Then add the extended datatype (YesNo) as a field, and name it “AddCheckDigit”.
2. Add this field to the “Setup field group”
Then we have the parameter in place, and it is available on the number sequence as shown earlier.
3. Then create a new class and replace all code with the following :
Here I’m creating an extension to the NumberSeq class, and I’m creating one method; Num, that will add the modulo10 number to my number sequence.
Where I check if my new “AddCheckDigit” is enabled, and I’m also saying that do not do this for continuos number sequences, manual, and I also say that the number sequence must be allowed to be changed to a higher number.
Now you can have check-digits on products, customers, vendors, sales orders, purchase orders etc.
PS! I have not tested this code 100%, but the community is full of brainpower that hopefully can share additional findings on bugs or flaws.
If you like this, vote at idea sat https://ideas.dynamics.com/ideas/dynamics-operations/ID0002954