Announcements
No record found.
SalesFormLetter salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice); SalesParmLine parmLine; SalesParmUpdate salesParmUpdate; //A SalesTable that already exists with one line unposted salesFormLetter.salesTable(initialSalesTable); salesFormLetter.transDate(invoiceDate); salesFormLetter.specQty(SalesUpdate::All); salesFormLetter.proforma(false); salesFormLetter.printFormLetter(false); salesParmUpdate = salesFormLetter.salesParmUpdate(); //Passing a NumberSequenceGroup string to a Custom field in order to allocate Invoice and Voucher num from this later salesParmUpdate.CustomNumberSequenceGroupId = numberSequenceGroup; salesFormLetter.createParmUpdateFromParmUpdateRecord(salesParmUpdate); salesFormLetter.initParmSalesTable(initialSalesTable); salesFormLetter.initParameters(salesParmUpdate, Printout::After); salesFormLetter.initLinesQuery(); //Remove lines of Sales Order that don't belong to this process while select parmLine where parmLine.ParmId == salesFormLetter.parmId() { if(!someMap.exists(parmLine.SalesLineRecId)) { parmLine.selectForUpdate(true); parmLine.delete(); } } salesFormLetter.run();
Hi @Vasileios,
Thanks for sharing the detailed context — really helpful in understanding the issue.
Since the same logic works when triggered from the UI but fails in code, and given your suspicion about SalesParmUpdate inconsistencies, a few things to consider:
SalesParmUpdate
CustomNumberSequenceGroupId
initParameters()
run()
info()
debug
salesFormLetter.salesParmUpdate().CustomNumberSequenceGroupId
SalesParmLine
Also, I highly recommend checking out this article by Gaurav Gulati: 🔗 How to debug sandbox/UAT environment in D365FO It walks you through how to attach a debugger to a sandbox/UAT environment — super helpful in scenarios like this when code behaves differently in non-dev tiers.
Let us know how it goes once you try these steps.
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.
Congratulations to our 2026 Super Stars!
Thanks to all of our 2025 Community Spotlight stars!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Giorgio Bonacorsi 617
André Arnaud de Cal... 461 Super User 2026 Season 1
Syed Haris Shah 298 Super User 2026 Season 1