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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Cannot edit a record in Number sequence code (NumberSequenceTable). Number sequence code: xx_1, x_1. Deadlock, where one or more users have simultaneously locked the whole table or part of it

(0) ShareShare
ReportReport
Posted on by 465

Hi,

So i have a service that creates multiple orders. However, when it gets called, sometimes i get this deadlock error. What should i do. (it seems it happens when inserting to tabe1 below)

class 11OrderCreationService
{

    public List createOrder(List _orders)
    {
        List                            response    = new List(Types::Class);

        ListEnumerator                          orderEnum;
        AAOrderCreationReqContract      reqContract;

        if(_orders)
        {
            orderEnum = _orders.getEnumerator();

            if(orderEnum)
            {
                while (orderEnum.moveNext())
                {
                    reqContract = orderEnum.current();

                    response.addEnd(this.createSingleOrder(reqContract));
                
                }
            }
        }

        return response;
    }
    public void createSingleOrder()
    {
        try
        {
          // logic
          //logic
          
          ttsbegin;
              AA orderCreation = new AA();
              orderCreation.create();
          ttscomitt;
        }
        catch
        {
            for (currentLine = startLine   1; currentLine <= Global::infologLine(); currentLine  )
                {
                    errorMsg  = stage   ' : '  infolog.text(currentLine)   '\n';
                }
            startLine = currentLine - 1;
    
            resContract= new 11Response();
    
            resContract.ErrorMessage(errorMsg);
        }
    
    }
}

class AA
{
    public void create()
    {
        this.createHeader();
        while (listOrderLinesEnum.moveNext())
        {
            Table1 table1;
            table1.initValue();
            //continue initializing fields
            table1.insert();
        }
            
    }
}

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,049 Super User 2025 Season 2 on at

    Hi D365FO user,

    Can you check if you have the number sequence set to continuous or not? The continuous number sequences are requiring more logic and database interactions.

    When the continuous setting is enabled, you can also enable the pre-allocation of numbers.

    If above is not helping, you can look for SQL logs or activity about blocking sessions to learn what exact tables and calls are causing this behavior.

  • Suggested answer
    WillWU Profile Picture
    22,361 on at

    Hi D365FO user,

    Please try to use try/catch Statements to avoid it,  reset state and retry when a deadlock is encountered.

     try
        {
            table1.insert();
        }
        catch (Exception::Deadlock)
        {
            //TODO: reset the state of the table
            retry;
        }

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans