Question

I have gone through msdn article, read whitepaper on number sequences 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).

Était-ce utile?

La solution

I am able to suppress the exception by using following;

num = NumberSeq::newGetNumFromCode(<<someNumberSequenceCode>>, 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.

Autres conseils

Please have a look at your number sequence that you have set up. I recon it has something to do with the numbersequence scope.

Make sure the scope of the number sequence is valid within the company you are calling this.

It's work, but not raice result: Voucher not generated.

Working way:

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

When my Number Sequence - Scope is setup as Shared I can use this code:

numSequence = NumberSeq::newGetNumFromCode(<<someNumberSequenceCode>>, NumberSeqScopeFactory::createDataAreaScope(curext()), true, true);

When my Number Sequence - Scope is setup as Company I can use this code:

numSequence = NumberSeq::newGetNumFromCode(<<someNumberSequenceCode>>);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top