Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Cannot call NEXT, update() or delete() on buffer where data is selected or inserted in another transaction scope

Posted on by 2,005

We are experiencing a strange error when attempting to call the updateReservation() method of an InventMovement object. If the item that is in the InventMovement object has an OnOrder quantity in the InventSum table, we receive the following error:

Cannot edit a record in Order Lines (SalesLine). Cannot call NEXT, update() or delete() on buffer where data is selected or inserted in another transaction scope.

It turns out that the InventUpd_Reservation.updateNow() method is not called unless the item is OnOrder. However, after checking the calling class, which is a custom class I created, I do not see anywhere else that we access that SalesLine in any transaction scope. The InventMov_Sales object is not created until right before we call the updateReservation() method and the InventUpd_Reservation object is passed the existing InventMov_Sales object via the InventUpd_Reservation::newMovement() static method. I thought perhaps that InventUpd_Reservation was creating a new InventMovement object, thus causing the error, but it doesn't--it uses the same one.

Does anyone have any idea why this might be happening?

Brandt

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Cannot call NEXT, update() or delete() on buffer where data is selected or inserted in another transaction scope

    Hi
    I do not know if this has been solved already but we got the same error and the solution was to change the transaction scope.

    Does not work and error is created:

    select forupdate * from sysPersonalization where sysPersonalization.UserId == userInfoId;

    if(sysPersonalization)
    {

    perm.assert();
    ttsBegin;
    sysPersonalization.delete();
    ttsCommit;
    CodeAccessPermission::revertAssert();
    }

    Does work an no error is created:

    ttsBegin;
    select forupdate * from sysPersonalization where sysPersonalization.UserId == userInfoId;
    if(sysPersonalization)
    {
    perm.assert();
    sysPersonalization.delete();
    CodeAccessPermission::revertAssert();
    }
    ttsCommit;

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Cannot call NEXT, update() or delete() on buffer where data is selected or inserted in another transaction scope

    Hi Brandt Fundak

    There might be data that is being update or delete which belongs to other legal Entity (Company). So, get into that method to see what data is being Updated (Update, Deleted). 

    Regards.

    Kumar

  • Klaas Deforche Profile Picture
    Klaas Deforche 2,431 on at
    RE: Cannot call NEXT, update() or delete() on buffer where data is selected or inserted in another transaction scope

    Also check this:

    gatesasbait.wordpress.com/.../table-caching-and-record-deleteupdatenext

    It could be due to caching (salesline is set to NotInTTS by default)..

    Do you have code anywhere where the transaction is begun after the record has been selected forupdate?

  • Klaas Deforche Profile Picture
    Klaas Deforche 2,431 on at
    RE: Cannot call NEXT, update() or delete() on buffer where data is selected or inserted in another transaction scope

    Can you share the code that throws that error? What happens if you reselect that record before you update it? Or is that not feasible?

  • Brandt Fundak Profile Picture
    Brandt Fundak 2,005 on at
    RE: Cannot call NEXT, update() or delete() on buffer where data is selected or inserted in another transaction scope

    Unfortunately, I went back through the stack trace and at no point is a pessimistic lock set. Our global settings are set to use Optimistic locking per table and the SalesLine table is set to use the optimistic lock. At no point in the code that I can see is this overridden. Thank you for your reply however.

  • Klaas Deforche Profile Picture
    Klaas Deforche 2,431 on at
    RE: Cannot call NEXT, update() or delete() on buffer where data is selected or inserted in another transaction scope

    This blog post might help:

    community.dynamics.com/.../ax-support-for-pessimistic-locking.aspx

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans