Saleslines on order does not update

mo_xmo_x Member Posts: 50
I'm using events to modify some of the line fields on salesorder. The event runs using codeunit. O have subscribet to onaftermodify event, and when the fields get updated the values on the page doesnt change. When i use SalesLine.modify, the values on the pages gets updated but whem i post the order i get an error saying "Unable to change an earlier version of the Customer record. The record should be read from the database again. This is a programming error". Does anybody have a workaround or solution? Thanks


  • JuhlJuhl Member Posts: 724
    In OnModify triggers in Events, you must persist the changes, as event triggers operate in a separate transaction. So call Rec.Modify in the event.
    Follow me on my blog
  • mo_xmo_x Member Posts: 50
    Hey juhl,
    My code is following on onaftermodify:
    SalesLine2.setrange(docNo, Rec.docNo)
    SalesLine2.setrange(doctype, Rec.doctype)

    If salesLine2.findset then begin repeat
    //My statement here

    The first line(Rec) is actually main item, for example ItemA. And salesLine2 are lines below itemA, that gets added when itemA is added. Those has a relation. The insert part works perfect. But when i modify some fields then the problem occurs with the text above and the order page does not update the values.

    Inside the loop i calculate Qty to ship and invoice for the lines(salesline2). When qty to ship on itemA changes, salesline2 fields should also change. That is my problem now. Do you have any code example? Thanks.
Sign In or Register to comment.