Dynamics 365 : 在编号序列中添加数字校验位 / Dynamics 365 : Adding check-digits to number-sequences – ww12345678 的部落格 | AX Helper
最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

Dynamics 365 : 在编号序列中添加数字校验位 / Dynamics 365 : Adding check-digits to number-sequences

网络文摘 William 311浏览 0评论
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 table, 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. That’s it 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.



  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址