/ Microsoft / Custom number sequence in D365FO

Custom number sequence in D365FO

Learn, share and spread knowledge

What is number sequence?

The number sequence is a series of numbers that are linked by a rule. It is very important for any ERP and business application. As, it saves the master and transnational data by an identifier. In this article, you will about how to develop custom number sequence in D365FO.

Custom number sequence in D365FO

Number sequences are used to generate readable and unique identifiers. In addition to this, these identifiers are used for the master data records and transaction records that require identifier.

Both Microsoft Dynamics 365 for Finance and Operations and Microsoft Dynamics AX 2012 are quite similar in terms of number sequences. But, in this tutorial you will only learn about how to develop custom number sequence in D365FO.

Let’s start!

  • Create extension of NumberSeqModule base enum
  • Add an element of your own module in the extension of base enum
  • I have added NevoiTech in the extension of NumberSeqModule base enum
  • Create a new string extended data type and named it as NevoiTechId
  • Create a new class NumberSeqModuleNevoiTech and extend it from NumberSeqApplicationModule

Add the following code in NumberSeqModuleNevoiTech class:

public class NumberSeqModuleNevoiTech extends NumberSeqApplicationModule
    protected void loadModule()
        NumberSeqDatatype datatype = NumberSeqDatatype::construct();
        datatype.parmReferenceHelp(literalstr("NevoiTech ID number sequence"));
        datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);

    [SubscribesTo(classStr(NumberSeqGlobal), delegateStr(NumberSeqGlobal,buildModulesMapDelegate))]
    static void buildModulesMapSubscriber(Map _numberSeqModuleNameMap)
        NumberSeqGlobal::addModuleToMap(classNum(NumberSeqModuleNevoiTech), _numberSeqModuleNameMap);

    static numberSequenceReference numRefNevoiTechId()
        return NumberSeqReference::findReference(extendedTypeNum(NevoiTechId));

    public NumberSeqModule numberSeqModule()
        return NumberSeqModule::NevoiTech;

Load number sequence

After doing all the above steps, create and execute the job as follows:

class LoadNumberSequenceJob
    public static void main(Args _args)
        NumberSeqModuleNevoiTech numSeq = new NumberSeqModuleNevoiTech();
        info("Number sequence loaded for NevoiTech module");

So, after loading the number sequence. Furthermore, you need to generate the number sequence. Go to the Organization administration -> Number sequences -> Number sequences -> Generate as shown in the picture below:

Generate number sequences from Organization administration
Generate number sequences from Organization administration

As a result, Set Up Number Sequences wizard will be started. Click Next -> Next -> Finish as shown in the pictures below:

Welcome - Set Up Number Sequences Wizard
Welcome – Set Up Number Sequences Wizard
Setup - Set Up Number Sequences Wizard
Setup – Set Up Number Sequences Wizard
Completed - Set Up Number Sequences Wizard
Completed – Set Up Number Sequences Wizard

Moreover, after successfully completing the wizard, generate number sequence.

Generate number sequence

Finally, you need to create and execute a new job to test your custom number sequence in D365FO as follows:

class GenerateNumberSequenceJob
    public static void main(Args _args)
        NumberSeq numSeq;
        NevoiTechId id;
        numSeq = NumberSeq::newGetNum(NumberSeqModuleNevoiTech::numRefNevoiTechId());
        id = numSeq.num();
        info(strFmt("%1", id));

Number sequence generated successfully

In this way, you can develop custom number sequence in D365FO. Moreover, if this helps you, please Like, Comment and Share to help other people.

If you found any ambiguity or a better solution, please feel free to ask.

Blog: Click here

YouTube: Click here

GitHub: Click here

There is no substitute for hard work. Never give up. Never stop believing. Never stop fighting. – Hope Hicks


Send Us A Message Here

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