Skip to main content

Notifications

Announcements

No record found.

Supply chain | Supply Chain Management, Commerce
Unanswered

Using ATL to generate purchase order data

(1) ShareShare
ReportReport
Posted on by
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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,405 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,455 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans