web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Unable to get next number in the sequence

(0) ShareShare
ReportReport
Posted on by 905

Hi All 

                I am trying to manually create the UserRequest object from the X++ code. However, I am unable to get the next sequence number for the "RequestId" field. I checked the Human resource setup parameters and found that it is using "Basi_3" sequence. Please find the below code and let me know why it is not working.

NumberSequenceTable numt;
NumberSequenceReference numR;

select numt
where numt.NumberSequence=='Basi_3';

select numR
where numR.NumberSequenceId==numt.RecId;

ttsbegin;
num = NumberSeq::newGetNum(numR);
info(num.num());
ttscommit;

Regards

Suresh

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    236,477 Most Valuable Professional on at
    RE: Unable to get next number in the sequence

    What's your version of AX? You have to deal with things like scopes in AX 2012.

    And what exactly happens? Do you get any error? Are all records found? What happens inside newGetNum()? We can't do the debugging for you...

  • Sureshnatababu Profile Picture
    905 on at
    RE: Unable to get next number in the sequence

    Sorry for not putting this clearly..I am working in AX 2012 and the number sequence is in the shared scope. The newGetNum() is returning  the sequence number starting from zero again , But if I look into the UserRequest form where this sequence is used, the sequence number has gone way ahead.

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Unable to get next number in the sequence

    try following code

    NumberSequenceTable numt;

    NumberSequenceReference numR;

    NumberSeq num

    select numt

    where numt.NumberSequence=='Basi_3';

    select numR

    where numR.NumberSequenceId==numt.RecId;

    num = NumberSeq::newGetNum(numR);

    num.parmMakeDecisionLater(true);

    info(num.num());

    you need to add additional line of code

    num.parmMakeDecisionLater(true);

    please verify and let me know if this helps you.

  • Sureshnatababu Profile Picture
    905 on at
    RE: Unable to get next number in the sequence

    Nitesh,

     Thanks for your reply. It doesn't work either. If I go and look into this sequence in the AX thick client, I find the next sequence value as 18 but if I run the code I am getting the value as 4. Is there any other way to get the next sequence number from a shared scope?

  • Martin Dráb Profile Picture
    236,477 Most Valuable Professional on at
    RE: Unable to get next number in the sequence

    You can simplify your code by using NumberSeq::newGetNumFromCode(). Pass the number sequence code and the scope into it. Verify the next number in the debugger - that guarantees that you're checking the same number sequence. Don't care too much about what's already in the table; it doesn't necessarily have to correspond to the number sequence.

  • Sureshnatababu Profile Picture
    905 on at
    RE: Unable to get next number in the sequence

    Thanks. What I finally found is that it is something to do with my current environment. I tried the same code in another environment and it worked. Thanks for all your help.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#3
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans