ERROR MESSAGE

When I delete Sales line I get error message : Another user has modified the record for this sales line after you retrieved it from the database. Enter your changes again in the updated window, or start the interrupted activity again. How to solve it?

How are you deleting th sales line?

Firstly is this something that happens just some times. In this case it is a case of multiple users editing the same line on the same invoice at the same time, this is a standard feature of Navision, and just needs user training. If this is a case where a particular action always causes the error, then it may be a code error. the most common one is where code in the Sales Line table modifies data in the Sales Header. This would require a slight restructuring of the code. As Jonathan says, what action is it that generates the error, then we can give you more help.

I think my codes make it the problem because I connect to server my self,No one else and make the error occur. I delete some line in Sales line and add some codes to update payment terms in Sales header in OnDelete trigger on sales line table. I think there is no strange in my code but why that happens?

quote:

… I think there is no strange in my code but why that happens?
Originally posted by Arnoldus - 2005 Jun 05 : 23:49:57

[Oops!] no actually it probably is your code. Of course if you actually told us what you were doing we could help [?]

This is my code on bottom of OnDelete Trigger in sales Line table : CLEAR(SalesLineCount); CLEAR(BlankPaymentTerms); CLEAR(CustPriceGroup); CLEAR(ItemGroup); SalesLine.RESET; SalesLine.SETRANGE(“Document Type”,“Document Type”); SalesLine.SETRANGE(“Document No.”,“Document No.”); IF SalesLine.FIND(’-’) THEN SalesLineCount := SalesLine.COUNT; IF SalesLineCount = 1 THEN BEGIN IF SalesHeader.GET(“Document Type”,“Document No.”) THEN BEGIN SalesHeader.VALIDATE(“Payment Terms Code”,’’); SalesHeader.MODIFY; END; END ELSE BEGIN SalesLine.RESET; SalesLine.SETRANGE(“Document Type”,“Document Type”); SalesLine.SETRANGE(“Document No.”,“Document No.”); SalesLine.SETFILTER(“Line No.”,’<>%1’,“Line No.”); IF SalesLine.FIND(’-’) THEN BEGIN IF Item2.GET(SalesLine.“No.”) THEN ItemGroup := Item2.“Item Disc. Group”; IF Customer2.GET(SalesLine.“Sell-to Customer No.”) THEN CustPriceGroup := Customer2.“Customer Price Group”; REPEAT Item2.RESET; IF Item2.GET(SalesLine.“No.”) THEN BEGIN IF ItemGroup <> Item2.“Item Disc. Group” THEN BlankPaymentTerms := TRUE; END; UNTIL SalesLine.NEXT = 0; IF BlankPaymentTerms = TRUE THEN BEGIN PaymentTerms.SETRANGE(“Customer Price Group”,CustPriceGroup); PaymentTerms.SETRANGE(“Item Group”,’’); IF PaymentTerms.FIND(’-’) THEN BEGIN SalesHeader2.GET(“Document Type”,“Document No.”); SalesHeader2.VALIDATE(“Payment Terms Code”,PaymentTerms.Code); SalesHeader2.MODIFY; END; END ELSE BEGIN PaymentTerms.SETRANGE(“Customer Price Group”,CustPriceGroup); PaymentTerms.SETRANGE(“Item Group”,ItemGroup); IF PaymentTerms.FIND(’-’) THEN BEGIN SalesHeader2.GET(“Document Type”,“Document No.”); SalesHeader2.VALIDATE(“Payment Terms Code”,PaymentTerms.Code); SalesHeader2.MODIFY; END; END; END; END; My logic : I delete a record or some records in Sales line and after that Payment Terms in Sales Header will refresh with NEW payment terms. Payment terms is filled based on Customer Price Group and Item Discount Group. For example : In Sales Line there is 3 record : Line 1 : CustPriceGroup : Diamond ; Item Discount Group : G Line 2 : CustPriceGroup : Diamond ; Item Discount Group : G Line 3 : CustPriceGroup : Diamond ; Item Discount Group : B IF I delete Line 3 → Payment terms must be : DiamondG IF I delete Line 2 → Payment terms must be : DiamondX //because Line 1 and 3 has different Item Discount Group IF I delete Line 1 and 3 → Payment terms must be : DiamondG IF I delete Line 2 and 3 -->Payment terms must be : DiamondG From my code ABOVE, THERE IS STRANGE IN MY CODE SO THE ERROR MESSAGE OCCUR ???

I think that this line: SalesHeader.VALIDATE(“Payment Terms Code”,’’); is what is causing the problem. The code behind it eventually validates the field VAT Base Discount %, where the OnValidate code modifies the same sales lines that you are working on, causing the contention. I would check to code on the Payment Terms Code to see if you actually need it to be done, then wrap that functionality in to your code here, or if you don’t need the code to occur, don’t validate it.

Torolf is right. The error can be avoided simply by adding a FIND; somewhere near the end of your code. This will retrieve the latest version of the Sales Line before deleting it.

Interesting method for applying a Payment Terms. But why don’t you just assign the Peyment Terms in the Release Function (CU414)?

Nearly always when you get this error, it is realted to you at some stage retrieving seperate records, and then rying to modify them each individually. i.e. SalesLine1.Find.. SalesLine1.Modify... SalesLine2.Find.. SalesLine2.Modify... works fine, where as ... SalesLine1.Find.. SalesLine2.Find.. SalesLine1.Modify... SalesLine2.Modify... does not. Follow the flow of your code, and restructure it so that there is no point where you have two open records modified that have not been written to disk (MODIFY).

Dear All, Payment terms have to be assign when User fill item in Sales Line so I may not assign in Release Code Unit with some reason in business process and after you delete line in Sales line,you have to refresh payment rerms in sales header. Yeah, I have to restructure my strange code [:D] and there is something in Onvalidate Payment terms. When I not validate it,the error NOT occur again. But if I not validate it,the code in Onvalidate trigger of payment terms can not be executed.there is a new problem,right?So,How to validate payment terms after delete line? The new problem occur too, when I click function → release in Sales Order, the error occur too, but I click release ONE MORE TIME,the error not occur and status become Released. Why I must click twice in relaease function? is there have connection with payment terms in header?

It may have nothing to do with Release. A more likely scenario is that you have made a change to the sales line, and focus remains on the sales line sub form. You then click on Release order (or press a button), this function os on the header, and thus focus now moves to the Header. At this point you now trigger th code that causes the error, i.e. Code int he line calls code that modifies a new version of the Header. But the second time you click release, you are now focused on the Header, and the record you are about to modify is the same record that you are on, so this time ther is no conflict and the process works. To confirm that this is correct, do the following: Make the change on the sales line (delete. modify or what ever it is) then before clicking anything else, close the sales order by clicking the X. Reopen the Sales Order, and immediately try to relase the order. If this works, then you know that it is a focus issue, and yo have NO option but to redesign your code. In fact you may have to scrap what you have done and start again, since you will just waste far more time debugging what you have that re-writing.