Monsieur Winner

MS D365FO || Monsieur D365FO

D365foTechnical

Form Data Field Onmodified event handler in D365FO

Bonjour les Amis.

A short snippet to show how to use the OnModified field event handler in D365FO.

Event handlers are available on different part on a Form in D365FO: On the Form datasource, form control, form object itself.

In this post we are working on a Form datasource.

I added a custom field “JournalId” on the LedgerJournalTransTable. The aim here, is to link Item movement journal transaction(s) with the General journal, So when I select the journal Id on the form, I will be able to perform some actions.

Firstly I locate my field on the LedgerJournalTrans Form Datasource.

 

 

/// <summary>
/// Return Total cost amount from Inventory movement journal lines.
/// </summary>
/// <param name=”sender”></param>
/// <param name=”e”></param>
[FormDataFieldEventHandler(formDataFieldStr(LedgerJournalTransDaily, LedgerJournalTrans, JournalId), FormDataFieldEventType::Modified)]
public static void JournalId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
{
FormDataSource LedgerJournalTrans_ds = sender.datasource();
LedgerJournalTrans ledgerJournalTrans = ledgerJournalTrans_ds.cursor();

InventJournalTrans inventJournalTrans;

select Sum(CostAmount) from inventJournalTrans where inventJournalTrans.JournalId == ledgerJournalTrans.JournalId;

ledgerJournalTrans.AmountCurDebit = inventJournalTrans.CostAmount;
}

Merci.

 

admin

Komi Siabi is a Bilingual D365FO Solution architect who loves sharing his knowledge as he works on Both Francophone and Anglophone projects around the globe. He enjoys doing some tiktok videos in his leisure time.

Leave a Reply

Your email address will not be published. Required fields are marked *