Saturday, March 9, 2019

D365 Form Init Event handler Pre and Post FormEventType::Initialized

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
        }
    }

2 comments:

  1. Thanks for posting the useful information to my vision. This is excellent information.
    Microsoft Dynamics AX Online Training

    ReplyDelete
  2. Dynamic Netsoft Technologies is a Microsoft gold partner with more than decade plus experience. Contact our experts, if you're looking up for a Microsoft Dynamics ERP Partners to upgrade your system

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...