Cancel a specific Sales Line, using code (X++)
Views (4508)
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
-
@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..?
-
-
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.
-
hi Sohaib,
Thanks for the information. What if I want to cancel all of the sales lines on an order?
Thanks again!

Like
Report
*This post is locked for comments