Creating a new number sequence Number sequences in Dynamics 365 for Finance and Operations are used to generate specifically formatted number sequence for record identification.
These number sequences can be anything from sales ordernumbers or transaction identification numbers to customer or vendor accounts. When developing custom functionality, often one of the tasks is to add a new number sequence to the system in order to support newly created tables.
Adding a number sequence to the system is a two-step process. First, we create the number sequence itself; second, we start using it in some particular form or from the code. D365 contains a list of NumberSeqApplicationModule derivative classes, which hold the number sequence's setup data for the specific module. These classes are read by the number sequence wizard, which detects existing number sequences and proposes to create the missing ones or newly added ones. The wizard is normally run as a part of the application initialization. It can also be rerun any time later when expanding the D365 functionality used, where a setup of additional number sequences is required. The wizard also has to be rerun if new custom number sequences are added to the system.
Create a new NumberSequenceModuleCustomerGroup class in the D365 Project that extends the NumberSeqModuleCustomer class in the Application and add the following code snippet at the bottom of the loadModule_Extension() method:
class NumberSequenceModuleCustomerGroup 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);
}
Create a new runnable class (Job) with the following lines of code, build the2. solution and run it:
class loadNumSeqCustombeGroup
{ /// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void Main(Args args)
{
//define the class variable
NumberSequenceModuleCustomerGroup nymberSeqMod = new NumberSequenceModuleCustomerGroup ();
//load the number sequences
nymberSeqMod.loadModule_Extension();
}
}