Steps to create number sequence in D365FO

ms-dynamics-365-header

The main purpose of Number sequence is to be used as unique identifier, readable alphanumeric number for Master data or can be used as business Id for transaction details records.

In general there is no difference between creating new number sequence in AX 2012 and D365FO

Scenario in few steps :

In my case i have a new specific module, the name of my module is MyNewD365Module

Step 1 : Create a new extension of « NumberSeqModule » standard base enum, and add my enum value. which represent the name of my D365FO Module.

NS1

Step 2 : Create a new EDT, which will represent the value of your number sequence Id.

My EDT name is : MyNumSeqEDT

NS2

Step 3-1 : Create new parameter table,

Just like accounts receivable or project management, Each new module must have a global parameter table, in our case « MyNewTableParameter » will contain the basic setup information for the new module. this include the default information and the options that determine how the processes within « MyNewD365ModuleEnum » module operate.

Step 3-2 : Add new method to parameter table

Add the Following method:

    public client server static NumberSequenceReference numRefID()
{
return   NumberSeqReference::findReference(extendedTypeNum(MyNumSeqEDT));
}

 

Step 4 : Create a new class, which extend from « NumberSeqApplicationModule » standard class, and add the following method.

    public void loadModule()
{
NumberSeqDatatype datatype = NumberSeqDatatype::construct();datatype.parmDatatypeId(extendedTypeNum(MyNumSeqEDT));
datatype.parmReferenceHelp(« My Number Seq ID »);
datatype.parmWizardIsContinuous(false);
datatype.parmWizardIsManual(NoYes::No);
datatype.parmWizardIsChangeDownAllowed(NoYes::Yes);
datatype.parmWizardIsChangeUpAllowed(NoYes::Yes);
datatype.parmSortField(1);
datatype.parmWizardLowest(1);
datatype.parmWizardHighest(9999);
        datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);
this.create(datatype);
}

In this method i configure the static information for data type that will be associated with my number sequence by passing number of parameters, some of them are optional.

  1. I can indicate if the number sequence is continious and Manual by default or not for the associated EDT.
  2. If an administrator can change the value of the next number in a number sequence backward / forwards or not.
  3. Minium, Maximum value

Complet class code :

class MyNumberSeqModule extends NumberSeqApplicationModule
{
public void loadModule()
{
NumberSeqDatatype datatype = NumberSeqDatatype::construct();
datatype.parmDatatypeId(extendedTypeNum(MyNumSeqEDT));
datatype.parmReferenceHelp(« My Number Seq ID »);
datatype.parmWizardIsContinuous(false);
datatype.parmWizardIsManual(NoYes::No);
datatype.parmWizardIsChangeDownAllowed(NoYes::Yes);
datatype.parmWizardIsChangeUpAllowed(NoYes::Yes);
datatype.parmSortField(1);
datatype.parmWizardLowest(1);
datatype.parmWizardHighest(9999);
        datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);
this.create(datatype);
}
    public NumberSeqModule numberSeqModule()
{
return NumberSeqModule::MyNewD365Module;
}
}
Step 5 : Create new Job (Batchable class), and run to load it
class loadMyModule
{
/// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = « _args »>The specified arguments.</param>
public static void main(Args _args)
{
MyNumberSeqModule numberSeq = new MyNumberSeqModule();
numberSeq.loadModule();
}
}
Step 6 : After job execution, run Number Sequence Wizard
Accesible via: Orgnaization administration > Number Sequence ,
And then you can find your number sequence Id , adapted to 26 data area Id.
NS3
And the click generate, this will open new form to start number sequence generation process. your new number Sequence is well added
Here i’ve already Added a previous number sequence with EUK prefix.
Step 7 : Test your number sequence, run the following job :
static void number(Args _args){NumberSeq  numberSeq;MyNumSeqEDT num;numberSeq = NumberSeq::newGetNum(MyNewTableParameter::numRefID());num = numberSeq.num();info(num);}

Votre commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:

Logo WordPress.com

Vous commentez à l’aide de votre compte WordPress.com. Déconnexion /  Changer )

Photo Google

Vous commentez à l’aide de votre compte Google. Déconnexion /  Changer )

Image Twitter

Vous commentez à l’aide de votre compte Twitter. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l’aide de votre compte Facebook. Déconnexion /  Changer )

Connexion à %s