Hi
I am just dipping my toes into using the ATL framework, but am getting the following error when running the code below:
Microsoft.Dynamics.Ax.Xpp.ErrorException: 'Cannot edit a record in Purchase order lines (PurchLine).
Cannot call NEXT, update(), or delete() on buffer where data is selected or inserted in another transaction scope.'
private void postpostInvoiceForPurchOrder1()
{
var purchOrder = data.purch().purchaseOrders().find(purchId);
var purchOrderLine = purchOrder.lines().withLineNumber(1).firstEntity();
purchOrderLine.setReceiveNow(10).save(); // This is where the error is thrown
purchOrder.setDocumentState(VersioningDocumentState::Approved);
purchOrder.confirm();
purchOrder.postInvoice('INV#01', PurchUpdate::ReceiveNow);
}
I am using the library to generate data. My full scenario is that I need a purchase order with one line of 50 products, 40 of which are received (this bit works), and 10 are invoiced - this is the part above that is failing.
When I debug the code I can see that the purchase order line has been selected correctly, but the error is getting thrown from the super() call in the update() method of PurchLine.
Am I using the library correctly or have I missed something obvious. Any help would be much appreciated.
Thanks,
Joe