Create Number Sequence through number sequence code without reference

I have gone through this article…/aa608474.aspx and made number sequences a lot many times. But in this scenario I need some help.

Scenario is; I want to get next sequence number through x++ code using just number sequence code and no reference etc.

I have tried following (and many others but this is nearest solution) ;

static void myTestJob(Args _args)
NumberSeq num;

num = NumberSeq::newGetNumFromCode(‘SAO-Y’);

info(num.num()) ;

It generates number sequence against some number sequence codes, but for other it throws error that;

“Number sequence does not exist.”

I have tried many other options mentioned on many other blogs and tried to explore AX as well, but now need some assistance.

P.S. I’m not creating number sequence using x++ code but from front end (organization administration).

What code is throwing the error?

I’m getting error in the following highlighted line of code, but for some cases not for all.


Use debugger to step into the method and let us know when exactly it fails (in the case that it still won’t be obvious what’s wrong). And don’t forget to mention your version of AX.

Yea, I did. But now I think I am able to suppress the exception by using following;

num = NumberSeq::newGetNumFromCode(<>, NumberSeqScopeFactory::createDefaultScope(), true, true);

As, fourth optional parameter of NumberSeq::newGetNumFromCode(,true); says not to throw exception on missing reference.

boolean _dontThrowOnMissingRefSetUp = false,

As I said earlier, I have created number sequence from organization administration without writing any code (EDT, class, parameters table etc. stuff) so no reference was generated and I think I was getting exception due to this. Please verify.

So… you’re using AX2012 and there is no number sequence for the given code and (default) scope, correct? What do you expect then? Use would have to use a valid combination of number sequence code and scope.

Yea, I think I’m done! Thanks for you help, and by the way your posts always help a lot, and I created an account on this blog just to get support from you.