D365/AX7: Customer Settlement Using X++ Code


Customer Settlement of Invoice (Debit) and Payment (Credit) Using X++ Code.

Sample Code

[code language=”cpp”]

CUSTTABLE originator = CustTable::find(‘CAHM-1066’);
CustVendOpenTransManager SettleManager;
Custtransopen custtransopenfrom, custtransopento;
SettleManager = custVendOpenTransManager::construct(originator);

//finding debit amount record
select firstonly1 custtransopenfrom
where custtransopenfrom.AccountNum == originator.AccountNum
&& custtransopenfrom.RefRecId == 5637165579;

//finding credit amount record
select firstonly1 custtransopento
where custtransopento.AccountNum == originator.AccountNum
&& custtransopento.RefRecId == 5637172326;

SettleManager.updateTransMarked(custtransopenfrom, true);
SettleManager.updateSettleAmount(custtransopenfrom, 1); // settling with amount value 1
SettleManager.updateTransMarked(custtransopento, true);
SettleManager.updateSettleAmount(custtransopento, -1); // settling with amount value -1

One thought on “D365/AX7: Customer Settlement Using X++ Code”

  1. Hi,

    Do you have a similar script for reversal of this process to move the transaction out of closed transactions – as I have over 2k to process?


Leave a Reply