Hi,
I have to update Posting Date with TODAY on Sales Order every time I change record.
I have added following code on OnAfterGetRecord:
lr_SH.GET("Document Type","No.");
IF lr_SH."Posting Date" <> TODAY THEN BEGIN
lr_SH."Posting Date" := TODAY;
lr_SH.MODIFY(FALSE);
END;
If I use MODIFY I get following error message:
"A transaction must be started before changes can be made to the database"
If I don't use MODIFY then nothing happens, even with CurrPage.UPDATE(FALSE);
So how can I change Posting Date on every Sales Order I pass through?
Regards
Ann
0
Comments
Assuming this is on the Sales Order page (or form if you're on an older version), try just changing the code to:
Right now you're using a record variable to get a different instance of the record (not Rec being used on the page/form). So, if you don't MODIFY it, nothing happens. The above approach should change the field value on the current rec so you can carry on from there.
http://www.epimatic.com
http://www.epimatic.com
Hi Rob,
The thing is, which I didn't write, that I have also tried what you suggest. I have also tried to call a Function from T36, but no matter what, I get the same Transaction Error.
The interesting part is, when I leave a Message("No."), I get the next Sales Order number, when pressing Next.
But if I debug through my code, the Message("No.") is the number of the record, I want to leave.
Regards
Ann
http://www.epimatic.com