Hi,
I am encountering an error while posting a pending invoice using X++. I have a custom development where the user can post an invoice without a product receipt.
When I trigger invoice posting through my custom Post button, I create a pending invoice and use the below standard code to post it. However, I receive the following error on the first attempt:
"Cannot edit a record in Posted vendor invoice lines (VendInvoiceTrans). Update must be performed inside a transaction."
On the second attempt, the invoice posts successfully.
purchFormLetter.purchSelectLines(purchTableSet, purchLineSet, vendInvoiceInfoTable);
if (purchFormLetter.validate())
{
purchFormLetter.reArrangeNow(false);
purchFormLetter.run();
}
Could you please advise on how to resolve this issue?