Tuesday 12 August 2014

Calling number sequence from X++code in AX

At times we need to call the next number from a particular number sequence using X++ code.
Following is the code to do so:

static void numberSeq_Demo(Args _args)
{
NumberSeq    numberSeq;
int                   nextNo;
;
ttsbegin;

numberSeq = numberSeq::newGetNum
(NumberSeqReference::findReference(typeid2extendedtypeid(typeid(WaterConApplicationId))));
//WaterConApplicationId is the EDT that is used to create the number sequence.
info(numberSeq.num());

numberSeq = numberSeq::newGetNum
(NumberSeqReference::findReference(typeid2extendedtypeid(typeid(CustRelNo))));

nextNo =  numberSeq.num();

//info(strfmt("%1",nextNo));

ttscommit;
}

No comments:

Post a Comment