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
0
Answers
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.