How can i get rid of the error.

Jacob1227Jacob1227 Member Posts: 126
Hi All,

I have tried to change the sales order from codeunit.In that time i am getting the below error.

Microsoft Dynamics NAV
An attempt was made to change an old version of a Sales Header record. The record should first be reread from the database. This is a programming error. Identification fields and values: Document Type='Order',No.='1221'
OK


Can you please suggest me some steps to resolve this error.

Thanks in advance,
Jacob.A

Answers

  • vaprogvaprog Member Posts: 956
    This happens when you change the database record using two or more record variables. I don't understand all conditions, but the following triggers the error in my test environment (NAV 2018 CU 5).
     r1.GET;
      
      r2.GET;
      r2.value := 2;
      r2.MODIFY;
      COMMIT;
      
      r1.value := 1;
      r1.MODIFY; // Causes the error
    
    Even moving the assignment r1.value := 1 before the r2.GET prevents the error. Also removing the commit prevents it. Does NAV do some outOfOrder processing or copy on modify caching?

    So, I am confused about the details (has someone more insight?), but the general pattern is
    • read the record
    • modify the same record using a different instance of the record
    • modify the record
Sign In or Register to comment.