web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :

Cancel a specific Sales Line, using code (X++)

Sohaib Cheema Profile Picture Sohaib Cheema 49,668 Super User 2026 Season 1

Using x++  a specific sales line can be canceled, as demonstrated, in  below job. The code is simple to understand, as you will go through job.

static void sampleCancelSOLine(Args _args)
{
    boolean     ret;
    SalesLine   SalesLine;
   
    try
    {
        ttsBegin;       
       
        //Add your own logic to select and pass a specific sales line.
        SalesLine.clear();
        SalesLine   = SalesLine::findRecId(5637326141, true);   
        if(SalesLine)
        {
            //pass three parameters 
            //1.SalesLine buffer
            //2.remainSalesPhysical, pass it as zero as you want to cancel full line
            //3.remainInventPhysical, pass it as zero as you want to cancel full line
            ret         = SalesUpdateRemain::updateDeliveryRemainder(SalesLine, 0, 0);
   
            if(ret)
            {
                info(strFmt('Sales Line # %1: Canceled',SalesLine.LineNum));   
            }       
        }
        else
        {
            info('Sales line not found/Invalid Line');
        }
        ttsCommit;
    }
    catch
    {
        error("Sales line got exception while attempting to be canceled.");
    }
}

Comments

*This post is locked for comments

  • Sohaib Cheema Profile Picture Sohaib Cheema 49,668 Super User 2026 Season 1
    Posted at

    @Israel Gonzalez,

    I am not sure about R2 version. It has been a long time since R2 went out of support. I am sure there must be some alternative if this class is not there. Did you had a look of AOT..?

  • Israel Gonzalez Profile Picture Israel Gonzalez 746
    Posted at

    Hi Sohaib,

    I have not SalesUpdateRemain class. Does AX2012 R2 version has that class?

  • Sohaib Cheema Profile Picture Sohaib Cheema 49,668 Super User 2026 Season 1
    Posted at

    Hi JHickey,

    there are two possible ways

    1) loop every SO line, and pass it as buffer to cancel it

    2) have a look if any of the classes provides you option to accept SalesTable buffer? if so, just give it sales order and it should cancel all lines of it.

  • JHickey Profile Picture JHickey 95
    Posted at

    hi Sohaib,

    Thanks for the information. What if I want to cancel all of the sales lines on an order?

    Thanks again!