Sunday, May 22, 2016

How to: Generate number sequence for new developed module in AX 2012

In this post I am going to create a number sequence for newly developed module in AX 2012. 

1. Add a new element in NumberSeqModule baseenum with your new module name

2. Create a new Class NumberSequenceModuleModuleName extends NumberSequenceModule

3. Override loadModule method by adding the parameters of the sequence

    NumberSeqDatatype datatype = NumberSeqDatatype::construct();

    //Message ID: MessageID is a new EDT of string type
    datatype.parmDatatypeId(extendedtypenum(MessageID));
    datatype.parmReferenceHelp(literalstr("MessageId"));
    datatype.parmWizardIsManual(NoYes::No);
    datatype.parmWizardIsChangeDownAllowed(NoYes::No);
    datatype.parmWizardIsChangeUpAllowed(NoYes::No);
    datatype.parmSortField(2);

    datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);
    this.create(datatype);

4. Override numberSeqModule method

   public NumberSeqModule numberSeqModule()  
   {  
     return NumberSeqModule::NewModule;  
   }  

5. Create new job to load number sequence

   static void MessageIDNumSeqLoad(Args _args)
   {
      NumberSeqApplicationModule::loadAll();
   }  

6. Go to Organisation Administration | Common Forms | Number sequences | Number Sequences | Generate and follow the wizard to end to generate number sequence for new module.