01 February 2014

create new number sequence by x++ code in AX 2012

static void DemoNumberSeq(Args _args)
{
NumberSeq numberSeq;
Str salesId;
ttsbegin;
numberSeq = NumberSeq::newGetNum(SalesParameters::numRefSalesId());
salesId = numberSeq.num(); 
ttscommit;
info(strFmt("%1",salesId));
}

How it works
1.NumberSeq Table act as master table for numberseq code , which stores
format to be generated , next sequence etc.
2.NumberSequenceReferences stores all the references and their corresponding
numberseq codes.
3.As shown in the above code , NumberSeq class needs numberseqreference ,
i,e "EDT. Unique Id for the Process " So first get the references by
passing an EDT as parameter to the findReference method of numberseqreference
class.Than you can call numberSeq.num() method to generate the number
for you.
4.Use NumberSeqFormHandler class if you want to use the numbersequencs on form.

No comments:

Post a Comment

Give me the commetns and solutions

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension->...