Options

Saleslines on order does not update

mo_xmo_x Member Posts: 50
Hey,
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

Answers

  • Options
    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 juhl.blog
  • Options
    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
    SalesLine2.modify;
    Until SalesLine2.next=0;

    //mystatement:
    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.