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)

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

(0) ShareShare
ReportReport
Posted on by 272

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

I have the same question (0)
  • Suggested answer
    Ahsan Akhtar Profile Picture
    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
    272 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
    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

  • Community Member Profile Picture
    on at
    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
    272 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
    272 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
    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

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 2

#1
Guy Terry Profile Picture

Guy Terry 2 Moderator

#1
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans