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(); } |
Your comment is awaiting moderation.
Автор старается сохранить нейтральность, чтобы читатели могли сформировать свое собственное понимание представленной информации.