NumberSequence.used(); - When to use?

I have the following code:



It performs an insert and creates a new order fine but I get an error on the numberseq.used(); line, it says:

NumberSeq object not initialised.

However, If I comment out that line, it still performs an insert, so do I need to use the used(); method?

Eventhough if that line(numberseq.used()) is not written, code will insert the data correctly and it will work fine.

Numberseq.used() will only mark the number as used.

What is the purpose of that used method then? I’m porting the code over from AX2009 to AX2012 and in 2012 it throws the error but in 2009 it worked fine, so I’m just curious if it has been deprecated in 2012?

numberSeq.used(); // If everything is successful, and the number should be persisted
numberSeq.abort();// If something went wrong later, and the number should be cleared


But I don’t understand why I get the error? As the number sequence seems to work fine regardless…

I think you have to check if NumberSeq is created while you comment NumberSeq .used() , if yes so you don’t need to use NumberSeq.used() because ax do it by itself , else you have to check your class and verify that every thing is correct .