Help! I am running into an error when attaching a report in an SMTP mail. Usually, I get no error if I call the SMTP mail via Job queue and attach a report. So codewise, there's nothing wrong with my email codeunit with report attachment. The problem occurs when I call this codeunit from the ONVALIDATE event of the Requested Receipt Date field in the Purchase Order Card. Note that the source for the Purchase Order Card is Purchase Header. The source for the PO Report I am attaching is also Purchase Header. When I attach the PO Report in the email, I DO get the email with report attachment no problem. But since I am calling this code unit from ON VALIDATE event, I get an error "An attempt was made to change an old version of a Purchase HEader record. The record should first be reread from the database. THis is a pogramming error. Identification fields and values: Document Type='Order', No.='2223'". I need to use the ONValidate method of Requested Receipt or OnModifyRecord because I need to access the rec and xrec to email users of before and after value of mod.
Like I said earlier, the email gets sent with the PO Report attachment. The problem is on the PO Card, it complains with above error message.
Any ideas on how I could fix this? I am thinking maybe the error is because the current record in PO Card needs to be saved?
*This post is locked for comments
I have the same question (0)