Number sequence reset

You might recognize the scenario. You did install a new ISV solution or as a developer, you did create a new number sequence for an extended data type, but the new reference is not visible on the parameters form. How can you fix this issue? This post will describe the recommended solution for solving the missing number sequence reference.

Background

Since the day I started to work with Damgaard Axapta, there was already a need to add settings for new number sequences on parameter form. The partner I was employed at that time had their own add-on, but also for several implementations, there was a need to auto-populate primary key fields using a number sequence. When the software was installed before you created new legal entities, all the parameter forms did show the correct options for specifying the number sequences. However, when there is an ongoing implementation and new references should be added, they are missing from the parameter forms.

My most recent experience is at my current employer, To-Increase, where we invest in a new solution for Data Entry Workflow. Once the developer checks in the code, the software will be moved to a test environment where we can check the behavior and perform testing. This is similar to having an existing environment and installing a new solution or customizations. The first experience would be setting up the parameters and the number sequences. Again, we encountered, like many others did in the past 20 years, that the number sequences were not visible on the parameters.

To overcome this issue, we need to have new records initialized in tables for the Number sequence references (AOT name: NumberSequenceReference) and Data type number sequence properties (AOT name: NumberSequenceDatatype). In the past, I used various options to get this job done. By reverse-engineering you can find a static method in a class that will take care of the number sequence initialization when you create a new legal entity (NumberSeqApplicationModule::loadall()). Just calling this method did the trick, but I have to admit that sometimes I even added new records in the table manually.

Functional option

To prevent running scripts in Dynamics 365 to get the reference records available, especially in production environments, you should know that there is functional support in the standard application.

Reset function

Usually when talking about ‘reset’, you would have an association with reverting settings to a baseline. Starting from the Number sequences list page, there is an option as part of a drop-down menu Manual cleanup which is called Reset. The first thought is that this option would have a relation with the cleanup feature which is looping through a status list for continuous number sequences and will release records if the session where the reservation for a number was created doesn’t exist anymore.

Surprisingly, this Reset option is not changing existing number sequence data, but there is only one task part of this function and that is running the same number sequence initialization job which is executed as part of new legal entity creation. Note that during loading all number sequences, there might be a subtask that would clean up obsolete references. An example is the credit management module where two extended data types were obsolete.

When you start the Reset job, you need to confirm to start the job. After the execution is finished, the data types are available on the number sequences tab of the parameters form.

Now you can continue setting up the required parameters without having the need for technical involvement to make the references available. Note that some features are linked to a configuration key or part of localization. If the reset function is not working in these scenarios, first check if the configuration key and/or localization is active.

There is more…

As a developer, you can also decide to call the method (NumberSeqApplicationModule::loadall()) when creating a record in a new parameters table. Microsoft did do this themselves in the new Engineering Change Management module. You can find the example in the screenshot below. As the call is within the check if the parameter record already exists, it will not be called when a new number sequence is introduced. Then, you can rely on the Reset function as explained above.

If you want to learn how to develop number sequences using extensions, you can read a great post from José Antonio Estevan: Embrace the extensions mindset with Dynamics 365 for Finance and Operations | LinkedIn.



I do hope you liked this post and will add value for you in your daily work as a professional. If you have related questions or feedback, don’t hesitate to use the Comment feature below.


That’s all for now. Till next time!

4 replies
  1. Josh
    Josh says:

    Hi Andre,

    Is there any logic as to what options can be selected from the Number Sequence Code field?

    I created a new number sequence, but I can’t assign it to my reference as it doesn’t appear in the drop-down

    Any guidance would be much appreciated

    Thank you

    Josh

    Reply
    • André Arnaud de Calavon
      André Arnaud de Calavon says:

      Hi Josh,

      Depending on the number sequence reference design, the number sequence should be set up as global, with a legal entity or a company scope. Can you review and check which option you would need for your custom number sequence reference?

      Reply
      • Josh
        Josh says:

        Hi Andre,

        I think what we need would be a shared sequence as you mentioned, but if I configure the number sequence as shared, then the reference I require is not available for selection

        So if I understand correctly, this would require a change to the actual reference design, which I assume is a developer task, rather than functional. Is that correct?

        Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.