Multiple Customer Transaction Reverse by using X++
Scenario:
If user wants to reverse the bulk customer transaction
(irrespective of Customer account) based on the customer transaction txt column
(or any other column).
Code:
static void
Abs_CustTrans_Reverse(Args _args)
{
CustTrans
custtran,
custtranOut;
TransTxt
txt;
Counter counter;
boolean reversed;
TransactionReversal_Cust transsactionCust =
new TransactionReversal_Cust();
Args args = new
Args();
;
counter = 0;
//Counts how many records which we are
going to reverse
select count(RecId) from
custtranOut
where
custtranOut.Txt like 'sho*'
&& custtranOut.OrderAccount == '';
while
select custtran
where
custtran.Txt like 'sho*'
&& custtran.OrderAccount == ''
{
//Returns the reversed status
reversed = TransactionReversalTrans::findTransactionReversalTrans(tableNum(CustTrans), custtran.RecId).Reversed;
if(!reversed)
{
args.record(custtran);
new
MenuFunction(menuitemActionStr(TransactionReversal_Cust),
MenuItemType::Action).run(args);
counter++;
}
}
info(strFmt("Actual records %1 and reversed records %2",
custtranOut.recid, counter));
}
Happy coding!