Wednesday, June 26, 2024

How to cancel sales line in D365 F&O using X++

If there's a requirement to cancel a sales line through code X++ in D365 F&O, the following code can be used to achieve it. In this example, I’ve created an extension of the SalesLine table and added a new method that can be called to cancel the selected sales line.

[ExtensionOf(tableStr(SalesLine))]

final class SalesLine_Extension

{

    public void gauCancelSalesOrderLine()

    {

        ttsbegin;

        this.selectForUpdate(true);

        SalesUpdateRemain::construct().updateDeliverRemainder(this, 0, 0);

        ttscommit;

    }

}

No comments:

Post a Comment