Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Unanswered

Making Multiple Number Sequence for the same field

Posted on by 304

Hi all,

Hope you're doing fine.

I had to face a business need that requires to use several sequence number on the same field based on some selection from a list or an Enum, I didn't know how to do it at first, but I managed to do it.. so I'm sharing it with you, I hope it helps 

1- first you need to check if the targeted field has number sequence assigned or not, if yes… You need to either cancel the setup for this field or just make the number sequence manual

2- you need to create N number of EDT equals N number of sequence numbers you'll use

3- find the number sequence module you want your number sequences to belong to it and create N number of parameters data type like below:

    datatype.parmDatatypeId(extendedTypeNum("EDTname"));
    datatype.parmReferenceHelp(literalStr("EDT Name")); //this a string, so you write it with quotes like this "Sales Id", it's the reference help so describe it like you want
    datatype.parmWizardIsContinuous(true);
    datatype.parmWizardIsManual(NoYes::No);
    datatype.parmWizardIsChangeDownAllowed(NoYes::No);
    datatype.parmWizardIsChangeUpAllowed(NoYes::No);
    datatype.parmSortField(52); // that's not a constant value, just check for the last parameter number and add 1

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

you can change any value according to your business case

4- create a job that loads the number sequence module like below:

//assuming the number sequence module is NumberSeqModuleCustomer

    NumberSeqModuleCustomer   numberSeqMod;
    numberSeqMod = new NumberSeqModuleCustomer();
    numberSeqMod.load();

//run the job

5- create N number of methods in the table which holds the targeted field like below:

static client server NumberSequenceReference "method name"()
{
    return NumberSeqReference::findReference(extendedTypeNum("EDT name"));
}

6- after you check for the selection of your list or Enum, assign the field like below:

"TableName"."FieldName"= NumberSeq::newGetNum("TableName"::"MethodNameforspecificEDT"(),true).num();

  • CBNestor Profile Picture
    CBNestor 520 on at
    RE: Making Multiple Number Sequence for the same field

    Hi Kareem,

    thanks for the sharing. I am trying to apply the same logic but I having issues with some of the steps

    I am on the step numer 6. "after you check for the selection of your list or Enum, assign the field like below:"

    "TableName"."FieldName"= NumberSeq::newGetNum("TableName"::"MethodNameforspecificEDT"(),true).num();

    where is this assign?.

    I am trying to use two numSeq for ProdTable.ProdId. so when a new production is created it should ask me for the numSeq that I want to use, like dropdown list?

    I haven't work with number sequence by x++ before so some steps are new for me..

    thanks before hand for the help

  • KareemTaima Profile Picture
    KareemTaima 304 on at
    RE: Making Multiple Number Sequence for the same field

    Thank you, Martin

    I didn't know that there's the ability to start a bog here, I'll go for it

  • Martin Dráb Profile Picture
    Martin Dráb 225,490 Super User on at
    RE: Making Multiple Number Sequence for the same field

    This seems to belong to your previous thread, Multiple number sequence on the same field. I'll at least link those threads...

    Maybe you'd interested in starting a blog. Note that discussions forums are intended for discussion, which isn't the case of this thread.

    And when pasting code to the forum, please use Insert > Insert Code (in the rich-formatting view).

  • Anrini Profile Picture
    Anrini on at
    RE: Making Multiple Number Sequence for the same field

    Thank you for the share

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans