AX 2012: Generate next number sequence in X++

Often we do not need to generate the next number sequence manually in X++ since creating records by using forms the system automatically handles number sequence generation by invoking Number Sequence Framework.

However, sometimes we need to generate number sequences manually in X++. The following code helps you to do that:

static void numberSequence(Args _args)
    NumberSeq             numberSeq;
    SMAServiceObjectTable serviceObjectTable;

    numberSeq = NumberSeq::newGetNum(SMAParameters::numRefSMAServiceObjectId());

    serviceObjectTable.ServiceObjectId = numberSeq.num();


NumberSeq is the class in action here. Its static method newGetNum() takes NumberSequenceReference as an input parameter. All you need to do is to find the relevant number sequence reference in your case. Usually there are parm methods defined on Tables which give you the number sequence references.


One thought on “AX 2012: Generate next number sequence in X++

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s