Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

"Cannot edit a record in Order lines (SalesLine). The record shown has been updated by another user.

(0) ShareShare
ReportReport
Posted on by 270

I am updating my custom field that I've placed in the standard table SalesLine.

  [FormControlEventHandler(formControlStr(SalesAvailableDlvDates, TransferToConfirmedButton), FormControlEventType::Clicked)]
    public static void TransferToConfirmedButton_OnClicked(FormControl sender, FormControlEventArgs e)
    {
        SalesTable                              salesTable;
        SalesLine                               salesLine;
        SalesCalcAvailableDlvDates              salesCalcAvailableDlvDates;  
        SalesCalcAvailableDlvDates_SalesLine    salesCalcAvailableDlvDates_SalesLine;
        SalesCalcAvailableDlvDates_SalesTable   salesCalcAvailableDlvDates_SalesTable;
        SalesAvailableDlvDatesTmp               salesAvailableDlvDatesTmpSelected;
        FormRun                                 formRun = sender.formRun() as FormRun;
        FormControl                             DisableDlvDateControlButton = formRun.design(0).controlName('DisableDlvDateControlButton');
        FormDataSource                          salesLine_ds = sender.formRun().dataSource('SalesLine');
        HS_ConfirmedShipDate                    hs_ConfirmedShipDate;
        RecId                                   salesLineRecId;
                
        salesCalcAvailableDlvDates = formRun.args().caller();
        
        switch (classIdGet(salesCalcAvailableDlvDates))
        {
            case classNum(SalesCalcAvailableDlvDates_SalesLine):
                salesCalcAvailableDlvDates_SalesLine = salesCalcAvailableDlvDates as SalesCalcAvailableDlvDates_SalesLine;
                salesLine = salesCalcAvailableDlvDates_SalesLine.parmSalesLine();
                salesTable = salesLine.salesTable();
                break;

            case classNum(SalesCalcAvailableDlvDates_SalesTable):
                salesCalcAvailableDlvDates_SalesTable = salesCalcAvailableDlvDates as salesCalcAvailableDlvDates_SalesTable;
                salesTable = salesCalcAvailableDlvDates_SalesTable.parmSalesTable();
                break;

            default:
                break;
        }

        salesAvailableDlvDatesTmpSelected = sender.formRun().dataSource(formDataSourceStr(SalesAvailableDlvDates,SalesAvailableDlvDatesTmp)).cursor();
        salesLineRecId = salesLine.RecId;

        if(DisableDlvDateControlButton.visible() == false)
        { 
            ttsbegin;
            hs_confirmedShipDate.clear();
            hs_confirmedShipDate.SalesOrderNumber = salesLine.SalesId;
            hs_confirmedShipDate.ItemNumber = salesLine.ItemId;
            hs_confirmedShipDate.ItemName = salesLine.itemName();
            hs_ConfirmedShipDate.RefRecId = salesLine.RecId;
            hs_ConfirmedShipDate.OldPromisedDate = salesLine.ShippingDateConfirmed;
            hs_ConfirmedShipDate.NewPromisedDate = salesAvailableDlvDatesTmpSelected.AvailableShippingDate;
            hs_ConfirmedShipDate.Reason = "@HSP:ATPSimulateDeliveryDate";
            hs_confirmedShipDate.insert();
            ttscommit;
            
            if(SalesLine.HS_Reason != "@HSP:ATPSimulateDeliveryDate")
            {
                salesLine.clear();
                select forupdate HS_Reason from salesLine
                where salesLine.RecId == salesLineRecId;
                ttsbegin;
                salesLine.HS_Reason = "@HSP:ATPSimulateDeliveryDate";
                salesLine.doUpdate();
                salesLine_ds.refresh();
                ttscommit;
                info("@HSP:SalesOrderSaved");
            }
        }           
    }


The bold text is how I update the field. (my caller salesCalcAvailableDlvDates doesn't have any refresh/refreshEx/executeQuery. It returns this value. SalesCalcAvailableDlvDates_SalesLine). Every time I execute update my field, this error shows up:

"Cannot edit a record in Order lines (SalesLine). The record shown has been updated by another user. Press Revert or Shift+Control+F5 to see the updated values."

Why is this happening? I am only updating my custom field. 

*This post is locked for comments

  • Suggested answer
    Ahsan Akhtar Profile Picture
    Ahsan Akhtar 70 on at
    RE: "Cannot edit a record in Order lines (SalesLine). The record shown has been updated by another user.

    i fixed this issue by using this changes . please check screen shot . i hope . it will help you. ThanksCode-for-slution.png

  • Miguel Zuniga Profile Picture
    Miguel Zuniga 270 on at
    RE: "Cannot edit a record in Order lines (SalesLine). The record shown has been updated by another user.

    Hi Chaitanya.

    I already refreshed the salesLine_ds in both of the forms (parent and child) I am working on. But still the error is there.

  • Suggested answer
    Chaitanya Golla Profile Picture
    Chaitanya Golla 17,225 on at
    RE: "Cannot edit a record in Order lines (SalesLine). The record shown has been updated by another user.

    Hi,

    Refer the below link, though its on AX2012 but I feel it will work.
    (AX Issue: Cannot edit a record in Sales Orders (SalesTable). An update conflict
    occured due to another user process deleting the record or changing one or fields in the record)
    daxdude.blogspot.com/.../ax-issue-cannot-edit-record-in-sales.html

    Please update your code as below

    salesLine.clear();

    select * from salesLine // Either you can include recVersion in the fieldlist or can use all(*)
    where salesLine.RecId == salesLineRecId;

    ttsbegin;
    salesLine.selectforupdate(true);
    salesLine.HS_Reason = "@HSP:ATPSimulateDeliveryDate";
    salesLine.doUpdate();
    ttscommit;

    salesLine_ds.refresh(); //Moved outside the transaction block.

    Hope this helps you.

    Thanks,
    Chaitanya Golla

  • RE: "Cannot edit a record in Order lines (SalesLine). The record shown has been updated by another user.

    The problem is that you have updated the record through code, but the new values are not refreshed in the form.

    You may need to call, ds.reread, ds.refresh in the calling form.

    for example.

    Caller method in salestable form

    // call a method to update salesline

    salesline.reread();

    salesline.refresh();

  • Miguel Zuniga Profile Picture
    Miguel Zuniga 270 on at
    RE: "Cannot edit a record in Order lines (SalesLine). The record shown has been updated by another user.

    Anyone can help? 

  • Miguel Zuniga Profile Picture
    Miguel Zuniga 270 on at
    RE: "Cannot edit a record in Order lines (SalesLine). The record shown has been updated by another user. Press Revert or Shift+Control+F5 to see the updated values." Error. (Dynamics AX/D365)

    Hi Chaitanya.

    The reread() didn't work. Can you provide me links/documentation regarding this recVersion? How can that work?

  • Suggested answer
    Chaitanya Golla Profile Picture
    Chaitanya Golla 17,225 on at
    RE: "Cannot edit a record in Order lines (SalesLine). The record shown has been updated by another user. Press Revert or Shift+Control+F5 to see the updated values." Error. (Dynamics AX/D365)

    Hi,

    To resolve the issue you can either include recVersion in the fieldlist of salesLine (or) use salesLine.reread() before ttsbegin.

    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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,401 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans