If you are developing a custom form from scratch then yes, as @DAXaholic has pointed out you can override run
and init
methods directly on your form and then implement your custom logic there as you did in previous AX versions.
However overlayering is strongly discouraged in D365 and will no longer be supported by Microsoft. That means that if you are customizing a standard form or any other form which is not in the same package you have to use extensibility approach to implement custom logic. This can be achieved through extensions and event handlers.
Suppose you have a form and you have to execute some code before and after the form is initialized. Instead of overlaying the object and overriding init
method you can create an event handler class and subscribe to OnInitializing
and OnInitialized
events:
[FormEventHandler(formStr(Test), FormEventType::Initializing)]
public static void Test_OnInitializing(xFormRun sender, FormEventArgs e)
{
// your code here
}
[FormEventHandler(formStr(Test), FormEventType::Initialized)]
public static void Test_OnInitialized(xFormRun sender, FormEventArgs e)
{
// your code here
}