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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

how to assign NumberSequenceId = 0 in (NumberSeuquenceReference) table through x++ code for a particular company

(0) ShareShare
ReportReport
Posted on by

Hi,

Please let me know how could I assign NumberSequenceId = 0 in (NumberSeuquenceReference) table through x++ code for a particular company lets say I have company (207) .

Regards,

Mania

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    304,553 Super User 2026 Season 1 on at

    Hi Mania,

    Can you indicate the reason why you want to do this? It is not a normal request. To be able to get the company context, you have to link the NumberSequenceTable with the NumberSequenceScope table which has this information.

  • Community Member Profile Picture
    on at

    Hi Vilmos,

    Thanks for  your reply. Because The client is having a job by running which again the number sequences will get assigned properly to their respective parameters.  However the job will not update number sequence if there is a value already exists.

    So for that client wants me to assign 0 to NumberSequenceId , so that he can run the job

    Please let me know how could I do that using x++ code

    Regards,

    Mania

  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Please use the below job to update numbersequenceId to zero on numberSequenceTable for a given company. With this update you are removing reference to table NumberSequenceTable. Please test it on your test machine before you go further.

    static void NumberSequence(Args _args)

    {

       NumberSequenceTable numberSequenceTable;

       NumberSequenceReference numberSequenceReference;

       NumberSequenceScope     numberSequenceScope;

       NumberSequenceDatatype  numberSequenceDatatype;

       DataArea                dataArea;    

       while select numberSequenceReference

        //   where numberSequenceReference.RecId == 123 // To operate on specific record

       join numberSequenceScope

           where numberSequenceScope.RecId == numberSequenceReference.NumberSequenceScope

       join dataArea        

           where dataArea.id == numberSequenceScope.DataArea

           && dataArea.isVirtual == 0 //eliminates virtual company

           && numberSequenceScope.DataArea == "XYZ" // Specify company here

       join numberSequenceTable        

           where numberSequenceTable.RecId == numberSequenceReference.NumberSequenceId

           && numberSequenceTable.NumberSequenceScope == numberSequenceScope.RecId

       join numberSequenceDatatype // Holds Id of the EDT  

           where numberSequenceDatatype.RecId == numberSequenceReference.NumberSequenceDatatype;

       {

           ttsBegin;

           numberSequenceReference.selectForUpdate(true);

           numberSequenceReference.NumberSequenceId = 0;

           numberSequenceReference.update();

           ttsCommit;

       }

    }

    Thanks,

    Chaitanya Golla

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 39

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans