FORM INIT DATASOURCE PRE AND POST EVENT HANDLERS FOR INIT METHOD
How to get the event handler for the init method for Init method in D365 forms
You can just write the below code in any new class or else if you have an existing one then just simply copy the code in the class.
The class declaration should read:
[ExtensionOf(formStr(FormName))]final class FormName_Extension{}
So if the form name is SalesTable then the code will be
[ExtensionOf(formStr(SalesTable ))]
final class SalesTable_Extension{}
In some cases even a class without the extension signature i.e. [ExtensionOf(formStr(SalesTable ))] might not be required but in that case the this object will not provide the objects in the intellisense.
Note that the class declaration is Final and cannot be further extended.
[FormEventHandler(formStr(SalesTable), FormEventType::Initialized)]
public static void SalesTable_OnInitialized(xFormRun sender, FormEventArgs e)
{
FormDataSource SalesTable_ds = sender.dataSource(formDataSourceStr(SalesTable, SalesTableDS));
…
}
[PostHandlerFor(formStr(InventTable), formMethodStr(InventTable, init))]
public static void InventTable_Post_init(XppPrePostArgs _args)
{
FormRun fr = _args.getThis();
Common common = fr.args().record();
CustTable custTable;
if (common is CustTable)
{
custTable = common;
// do your coding here
}
}
No comments:
Post a Comment