web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / DAX Beginners / [D365/AX7] How to: Create n...

[D365/AX7] How to: Create number sequence

Christian Silva Profile Picture Christian Silva 707

Number sequences are used to generate readable, unique identifiers for master data records and transaction records that require identifiers. A master data record or transaction record that requires an identifier is referred to as a reference.

On this example, we are going to create a new number sequence for customer group.

Create a new class that extends the NumberSeqModuleCustomer class and then create the method loadModule_Extension and add the following code:

class NumberSeqModuleCustomer_CFS extends NumberSeqModuleCustomer
{
        public void loadModule_Extension()
        {
                NumberSeqDatatype datatype = NumberSeqDatatype::construct();

                datatype.parmDatatypeId(extendedTypeNum(CustGroupId));
                datatype.parmReferenceHelp("Customer group ID");
                datatype.parmWizardIsContinuous(false);
                datatype.parmWizardIsManual(NoYes::No);
                datatype.parmWizardIsChangeDownAllowed(NoYes::Yes);
                datatype.parmWizardIsChangeUpAllowed(NoYes::Yes);
                datatype.parmWizardHighest(999);
                datatype.parmSortField(20);
                datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);

                this.create(datatype);
        }
}

Important: As we can see on Application Explorer, NumberSeqModuleCustomer belongs to Application Suite model, make sure the model which you are using for development extends this model.Untitled picture

Like in Dynamics AX 2012, we still have to initialize the references manually by creating a Job (Runnable class) with the following code:

class loadNumSeq_CFS
{
        public static void main(Args _args)
        {
                NumberSeqModuleCustomer_CFS numberSeqMod = new NumberSeqModuleCustomer_CFS();
                numberSeqMod.loadModule_Extension();
        }

}

Before proceeding build the solution and run it.

On Dynamics 365, go to Organization administration/Common/Number sequence:Untitled picture

Click on Generate button:
Untitled picture

It will open Number Sequences Wizard, click on Next button:
Untitled picture

Note the number sequence codes and click on the Next button:
Untitled picture

On the last page, click on the Finish button to complete the setup:
Untitled picture

The last thing we should create is a method to consume our newly created Number Sequence, we are going to create a new extension class of CustParameters table and call it CustParameters_Extension.

[ExtensionOf(tableStr(CustParameters))]
final class CustParameters_Extension
{
        client server static NumberSequenceReference numRefCustGroupId()
        {
                return NumberSeqReference::findReference(extendedTypeNum(CustGroupId));
        }

}

And that’s all the steps. Soon I will be posting how to use our Number Sequence.
If you have any doubt about D365 extensibility, I recommend to read Tayfun Yaman’s 3 parts post about it.



This was originally posted here.

Comments

*This post is locked for comments