Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Select from Multiple Number Sequence for the same Field AX2012

(0) ShareShare
ReportReport
Posted on by 44

Hi All,

I am trying to setup multiple number sequence for the same field.

when creating Productions (choose from NP-#### or just ##### for the ProdId), this will also be replicated in other modules like in Purchase or sales orders.

I found this tutorial for ax2009 that I think it could fit with my requirement. But is not entirely compatible with AX2012. in the tutorial he is using a lookupNumberSequenceCode method that is not found in the number sequence Table (  NumberSequenceTable::lookupNumberSequenceCode(control, this.parmParentCode()); )

does anybody have this code somewhere? I would like to know how is implemented maybe I can adapt to the AX2012.

I also found this tutorial but I don't get the last Step where he assigns the table field to the number sequence.

any help is greatly appreciated

thanks a lot!

  • ergun sahin Profile Picture
    ergun sahin 8,812 Super User 2024 Season 1 on at
    RE: Select from Multiple Number Sequence for the same Field AX2012

    I don't know at what stage you created the number series, but it should have a feature such as undo when it is closed without using it.(numberSeq.used()/-/-/numberSeq.abort())

    Or you can put the code for generating the number sequence under closeOk (I haven't looked into the structure of the form, but I think the standard does something similar)

  • CBNestor Profile Picture
    CBNestor 44 on at
    RE: Select from Multiple Number Sequence for the same Field AX2012

    Now I understand what you say.

    so I have managed to create a Base Num for the ProdId numSeq selection and added as combobox control in the ProdTableCreate Form

    now the problem that I see is that if I close the form and open again. every time I do that the number sequence is incrementing... Is it possible to get it incremented only when the production is in fact really created (inserted in the ProdTable)?

    pastedimage1630054760239v1.png

    millon thanks again

  • ergun sahin Profile Picture
    ergun sahin 8,812 Super User 2024 Season 1 on at
    RE: Select from Multiple Number Sequence for the same Field AX2012

    I don't have much idea about lookupNumberSequenceCode. You should have a look at 2009, but it's probably not standard. I think it's a lookUp he wrote for the parent field he just added.

    If you copy the lookupReference method and write a method that will filter the new field, I think it will work. (This solution touches the standard structure too much. I wouldn't prefer it.)

  • Suggested answer
    ergun sahin Profile Picture
    ergun sahin 8,812 Super User 2024 Season 1 on at
    RE: Select from Multiple Number Sequence for the same Field AX2012

    Consider having more than one method in step 5.

    NumberSequenceReference NumSeqRefSales()

    NumberSequenceReference NumSeqRefPurch()

    .

    .

    All you have to do is use the relevant method at the time of generating the ID. You can make this decision with an enum (for example, if you have the custVendActype value)  or by choosing from a list. (or based on the code you're in)

  • CBNestor Profile Picture
    CBNestor 44 on at
    RE: Select from Multiple Number Sequence for the same Field AX2012

    Hi Ergün,

    I still have some doubts:

    1. Do you anyhow have the code for this table method in ax2009 NumberSequenceTable::lookupNumberSequenceCode() ?

    2. Do you know where to assign the field excacly from Step 6 from Kareem method?.

    " 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(); "

    in my case the table is ProdTable.ProdId and method ProdTable:ProdId_NP()

    3. Do you have any tutorial for this Sequence Group Structure you are mentioning .

    I am just beginning with handling number sequence by code. So I might no follow you that simple.

    thanks again for your help

  • ergun sahin Profile Picture
    ergun sahin 8,812 Super User 2024 Season 1 on at
    RE: Select from Multiple Number Sequence for the same Field AX2012

    I hadn't tried it the way Kareem did. Kareem create a number sequence in each module (sales/buying etc.) and gives it a different name. he write a method for each module in the table (using the names he give). He will choose method at the time of generating the number series.

    The first example, on the other hand, focused more on the operation of the standard field for more than one series in a single module.

    Apart from these, you can examine the number sequence group structure or you can open a numberSeqCode field for each module in a parameter table and directly get which series to use from there.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,784 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,476 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans