How To Use A D365 Number Sequence

Share this:

A D365 number sequence allows the system to generate a unique value. As well as use a defined format for the type of record being used. This is extremely helpful. There are sometimes, such as with item numbers, where you might have a specific value you use to already identify something. On the other hand, many other times, you want a unique value to be generated for you. And it saves time to have the system know and provide a unique value for you.

Overview

In order to use a D365 number sequence, there are a few steps. I think it is helpful to explain these steps at a high level before going into the detail.

First, you need to setup the number sequence, including defining the format. I will cover that next.

Secondly, as part of the setup, you need to define what Reference, or part of the system this number sequence is allowed to be used. As it will become clear, it would not make sense to associate a D365 number sequence to a type of record that does not match with the format that is defined.

Thirdly, on the parameters form of each module, there will be a ‘Number Sequence’ tab. On this tab, you will relate each type of record used in that module to a number sequence that will be used. As a result, any new record of that type that is created, will use the setup defined on that number sequence.

Fourthly, what happens if you have a new table and form that you want to use a number sequence? You may have noticed that there is a set list of records show on the parameters form. I will teach you how to add code to add a new table record that will show on this form. A user can then associate a number sequence to this type of record. Then, using some additional code, a unique value will be set on the record each time a new record is created. Learn how to develop a D365 number sequence.

Set Up Number Sequences

Before the system can generate a unique value for a D365 number sequence, the system needs to be told what the unique value should look like.

First, go to Organization administration>Number sequences>Number sequence.

In this form, you will see a list of all of the existing number sequences. They all will have a Number sequence code, along with a format. Importantly, anytime you see ‘#####’, these characters will be replaced by a unique number, when a record that uses that number sequence is created.

Additionally, you can use the ‘Area’ and ‘Reference’ drop downs to find the number sequence code that is used by a particular type of record in the system.

For example, set the ‘Area‘ to ‘Accounts receivable‘, the ‘Reference‘ to ‘Customer account‘, and the Company to ‘USRT‘. You will see the number sequence code used for this purpose.

Similarly, let us look at another example. Set the ‘Area‘ to ‘Sales‘, the ‘Reference‘ to ‘Sales order‘ and the Company to ‘USRT‘. This is the number sequence code used by sales orders in the USRT company.

To further understand, click on the blue text ‘Sale_322’ to drill into the number sequence details.

Scope

First, a D365 number sequence must have a unique ‘number sequence code‘. Secondly, it can have a name, and a scope. To explain, depending on what the ‘Scope’ is set to, a number sequence can be unique across the entire system. Or, just unique for the company that it is in.

Indeed, specifying a Company scope is common for tables that are not shared across companies. This reduces the chance that you will run out of unique numbers for a particular number sequence.

There are additional options for ‘Scope’ that are more complex. For example, the ‘Operating unit’ Scope can have multiple number sequences tied to each ‘Operating unit’ record created in the system.

Number Sequence Format

Next, a D365 number sequence has a defined format. Notably, this allows for more than just an incrementing number. To explain, the format can have different segments that make up the full value. Such as the legal entity, constants, and a segment that is an incrementing number. This is extremely useful.

In this example, the number sequence has one segment, that only contains ######. The ###### will be replaced by the system when the number sequence is used with numbers. And the value will always be unique.

With this in mind, a D365 number sequence can have more than one segment. Consider this example from Microsoft’s documentation:

SegmentsSegment typeValue
Segment 1Legal entityCS
Segment 2Constant-EXPENSE-
Segment 3Alphanumeric####

Example of formatted number: CS-EXPENSE-0039

As can be seen, a value that contains segments provides a lot more information to a user, than just a number. In this case, the user can understand what company this record was created in. Additionally, users know what type of record is being referenced, all without knowing any other context.

To provide another example, the Sales order number sequence often has a prefix of “SO-” to help users see it refers to a sales order.

SegmentsSegment typeValue
Segment 1ConstantSO-
Segment 2Alphanumeric######

Example of formatted number: SO-000029

Number Sequence References

Next, when setting up a D365 number sequence, you need to add a Reference. A Reference tells the system in what parts of the system this can be used. Otherwise, it would defeat the purpose of helping the user know what type of record it refers to, if the number sequence could be used everywhere.

Setup

Next, review the Setup fast tab.

Notably, a number sequence will be marked as ‘In use’ if a record contains a value generated from it.

The ‘Manual‘ flag should be set to ‘No‘, if you want the system to generate the next value.

Additionally, the ‘Next‘ field, shows what the next generated value will be. In rare cases, I have manually increases this value to be a higher value, to skip over an existing value. However, there are other ways to cleanup up and notify the system that a value is being used.

Similarly, there have been times when the ‘Next‘ value is the same as the ‘Largest‘ value. This means that all unique values are used up. Therefore, to fix this, you can add additional “#” characters to the format segment. This will increase the range of numbers the system can use when generating the next number.

Performance

Lastly, there are some performance controls when setting up a number sequence. For example, to improve performance, it is recommended to set the ‘Continuous’ flag to ‘No’.

Please see this Microsoft documentation for a further explanation of various performance considerations.

Create A Number Sequence

Often times, all of the number sequences you need are already created. However, if you wish to create a new numbers sequence, there are two ways.

First, go to Organization administration>Number sequences>Number sequence. Next, click the ‘Number sequence‘ button in the ribbon bar.

Then, fill out each section of the details form.

Alternately, click the ‘Generate’ button.

Presently, you will be shown a wizard. As seen, this wizard helps create one or more number sequences, using predefined formats. The system does this for number sequences that have not been created yet, for all the places in the system that use number sequences.

Click the ‘Next‘ button after reading the Welcome screen.

For example, the ‘Statement number’ number sequence has not yet been created a new store and operating unit. The wizard helps to notify the user that these need to be created. This is extremely helpful for the number sequences that are not tied to a module. But instead, are tied to a record.

Relating a Number Sequence To A Reference

Finally, you need to tell the system exactly which number sequence to use on each form or record. Most modules within Microsoft Dynamics 365 for Finance and Operations, have a ‘parameters‘ form. And, on most ‘parameters‘ form, there exists a tab named ‘Number sequence’. On this tab, specify what number sequence should be used for each Reference.

To demonstrate, go to Accounts Receivable>Setup>Accounts receivable parameters. Then, select the ‘Number sequences‘ tab.

Notice that the ‘Customer account’ reference is set to the D365 number sequence ‘Acco_331‘. This tells the system to use this number sequence to generate a new number whenever a new customer account record is created.

Unlike most grids in the system, this grid is prepopulated by the system with all the References in the system for this Module. When first setting up D365, it is up to the user to then specify a number sequence code for each row

Summary

In this article, I explained how a D365 number sequence is used by the system to generate a unique value. As well as to help users recognize what record a value is referring to by its format. Additionally, number sequences have quite a bit of setup that control the format, usage, and performance. Lastly, we went over how to relate a number sequence code to a Reference in the system. In the next article, I will explain how to create a new number sequence for a new reference. And use it in x++ code.

Peter Ramer
Peter Ramer is a part of the Managed Application Services team at RSM working on Microsoft Dynamics 365. He focuses on the Retail and Commerce industries. When he is not solving problems and finding ways to accelerate his clients' business, he enjoys time with his three kids and amazing wife.

Share this:

11 thoughts on “How To Use A D365 Number Sequence

Add yours

  1. Hi, Pedro Ramer

    I am new here, this part of How to use a D365 numerical sequence is very interesting and detailed, I would like to see on another occasion how to implement a numerical sequence through code in Visual Studio, the work you are doing on this page is very interesting.

  2. Hi Peter. Great post.

    Question on the scope field – on the operating unit scope option Is that available for all references in D365? I recall that was a limitation when we were trying to setup sales order number sequences for different units in the same legal entity

    1. I believe the operating unit scope is only available on some references. But I would need to check.

  3. hi Peter, if possible can you please explain the topic of work flows, how to create and how to use work flows and uses of work flow

    thank you in advance

  4. Bonjour Peter,
    Best wishes 2023 from France.
    If we choose “Legal entity and Fiscal calendar period”, we are obliged to return without stopping on the sequences pure to make those cu evolve according to the sandstone of the companies and periods ….. from where a restricted interest.
    Isn’t it possible to say that the same sequence code including “Legal entity and Fiscal calendar period” can be used for all legal entities… In other words the system automatically feeds the data with the company in which I am working and the period I’m in….or like in Business Central upload an excel file in which all my sequences are created for the next 5 or 10 years with an activation date start end of sequence…
    Thanks in advance
    Best regards
    Thierry

  5. Would it be possible to get the alphanumeric segment of a field generated by number sequence, regardless of the format? For example, finding the numbers of a PurchId when format can change across legal entities.

    1. There isn’t an automatic way to do. You likely could write some code that just pulls all numbers from the field and strips out the letters. I’m curious how you would use this information though.

Leave a Reply

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

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑