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.
Your comment is awaiting moderation.
Someone essentially help to make seriously posts I would state. This is the first time I frequented your website page and thus far? I amazed with the research you made to make this particular publish amazing. Fantastic job!