Error while trying to update a sales order

Hi everyone,

For some particular customers(I added a flag blnXXX in tab 18 to differentiate them), I need to do the following:
In a Sales Order, when typing the sell-to Customer code, a page pops up with some values from the customer card (name, address,etc). When I modify them in the pop up page, the Sales Order must get updated with the values I introduced.
I placed the following code in the OnValidate trigger of Sell-to Customer No. in tab 36:

IF blnXXX THEN BEGIN
CLEAR(pageXXX);
pageXXX.SETTABLEVIEW(Rec);
pageXXX.LOOKUPMODE :=TRUE;
pageXXX.RUNMODAL;
END;

and the following code in the OnClose page trigger of the pop up page:

SalesHeader.GET(SalesHeader."Document Type"::Order,"No.");
SalesHeader."Sell-to Customer Name" :=NewCustName;
SalesHeader."Sell-to Customer Name 2" := NewCustName2;
.
.
.
IF SalesHeader.MODIFY THEN;
COMMIT;

When I run the Sales order, do a change in the pop up page and then click OK, I get the following erro message:

An attempt was made to change an old version of a Sales Header record.The record should be first reread from the database.This is a programming error.

The debugger stops at the following instruction in trigger OnValidate of Sell- to Customer No.(function SelltoCustomerNoOnAfterValidat) in Sales Order page:

CurrPage.UPDATE;

I can’t figure out how to modify my code to make it work.
Any suggestions?

Thanks in advance :mrgreen:

Hi ,

Try a currpage.update(false) or a commit prior to this .

g.

Hi Poppins,

Did this suggestion help you? If yes please verify, if not, please elaborate with a few more details. [:)]