Tuesday, November 9, 2021

UPDATE CUSTOM FIELDS IN CUSTTRANS/VENDTRANS FROM LEDGERJOURNALTRANS DURING THE POSTING OF JOURNAL D365 fo x++

Original post: https://allaboutdynamic.com/2018/06/25/d365-ax7-update-custom-fields-in-custtrans-vendtrans-from-ledgerjournaltrans-during-the-posting-of-journal/

 Need to update/carry/flow Custom Fields In CustTrans/VendTrans From LedgerJournalTrans during the posting of journal.

Sample Code

[ExtensionOf(classStr(CustVendVoucher))]

final class AcxCustVendVoucher_Extension

{

public void post(

LedgerVoucher _ledgerPostingJournal,

CustVendTrans _custVendTrans,

NoYes _approval,

UnknownNoYes _euroTriangulation,

boolean _withHoldTaxType,

boolean _useSubLedger)

{

LedgerJournalTrans  ledgerJournalTransLocal;

VendTrans   vendTransUpdate;

Common  commonLocal = common;




next post(_ledgerPostingJournal, _custVendTrans, _approval, _euroTriangulation, _withHoldTaxType, _useSubLedger);

if (commonLocal.TableId == tableNum(LedgerJournalTrans))

{

ledgerJournalTransLocal = commonLocal;

if (_custVendTrans.tableid == tableNum(vendTrans))

{

ttsbegin;

//*******NOT Recommended*********

//either update in vendTrans or custtrans

select firstonly1 vendTransUpdate

where vendTransUpdate.RecId == _custVendTrans.RecId;

vendTransUpdate.selectForUpdate(true);

vendTransUpdate.DocumentNum = ledgerJournalTransLocal.accountName();

vendTransUpdate.doUpdate();

ttscommit;

//*******Recommended*********

//or insert record with reference of VendTrans.RecId into a seperate table like AcxVendTrans

}

}

}




}


1 comment:

  1. To update custom fields in CustTrans/VendTrans HostMyCode from LedgerJournalTrans during journal posting in D365 FO X++, you can override the post method in LedgerJournalTrans and add your update logic for the custom fields there.






    ReplyDelete

Power Automate vs Azure Logic Apps vs Azure Data Factory: What They Are, When to Use Them, and How to Integrate Non-Microsoft Systems

  In today’s cloud-first, API-driven enterprise landscape, automation and integration have become vital pillars of operational agility. Micr...