Monsieur Winner

MS D365FO || Monsieur D365FO

Technical

FORM Event handlers in D365FO.

To extend existing functionality in D365FO, we make use of event handlers on Forms, tables, classes..

Here are some events handler samples.

 

Form datasource from xFormRun

[FormEventHandler(formStr(SomeForm), FormEventType::Initialized)]

public static void SomeForm_OnInitialized(xFormRun sender, FormEventArgs e)

{

FormDataSource MyRandomTable_ds = sender.dataSource(formDataSourceStr(SomeForm, MyRandomTableDS));

}

Get FormRun from form datasource

[FormDataSourceEventHandler(formDataSourceStr(MyForm, MyRandomTableDS), FormDataSourceEventType::Written)]

public static void MyRandomTableDS_OnWritten(FormDataSource sender, FormDataSourceEventArgs e)

{

FormRun formRun = sender.formRun() as FormRun;

formRun.myCustomMethod();

}

Get FormRun from form control

[FormControlEventHandler(formControlStr(MyForm, MyButton), FormControlEventType::Clicked)]

public static void MyButton_OnClicked(FormControl sender, FormControlEventArgs e)

{

FormRun formRun = sender.formRun() as FormRun;

formRun.myCustomMethod();

}

Access form control from xFormRun

[FormEventHandler(formStr(SomeForm), FormEventType::Initialized)]

public static void SomeForm_OnInitialized(xFormRun sender, FormEventArgs e)

{

sender.design().controlName(formControlStr(SomeForm, MyControl)).visible(false);

}

Get current record in form control event

[FormControlEventHandler(formControlStr(SomeForm, SomeButton), FormControlEventType::Clicked)]

public static void SomeButton_OnClicked(FormControl sender, FormControlEventArgs e)

{

SomeTable callerRec = sender.formRun().dataSource(1).cursor();

}

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.

0 thoughts on “FORM Event handlers in D365FO.

  • Your comment is awaiting moderation.

    Автор старается сохранить нейтральность, чтобы читатели могли сформировать свое собственное понимание представленной информации.

    Reply

Leave a Reply

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