Not a 'New' Concept : Event Handler Methods in Dynamics 365 F&O
Remember
the old days of having the ability to simply override the AX Form methods (i.e.
Init, Lookup etc). It was fairly quick and easy way to do Form Customization. Well,
this won’t be the case anymore as New Dynamics 365 F&O stops this ability
to do in above manner. But please note it doesn’t mean these kinds of
Customization is not available. Microsoft simply enforce us to do this kind of
Customization in a different manner using Event Handler.
· As we may know already this approach supports Microsoft’s
strategy to write your Customized Code in Extensions (No More Over-layering /
In-Line Code).
Also, please note that the Event Handler Option is not a brand-new
concept and in fact it existed in Previous version (AX 2012). The difference is
it was there as option before but now it is mandatory for such Customization.
Creating an Extension Class for Forms Code
To create an extension class for forms code, we can create
a class which ends in _Extension. We only need to have the ExtensionOf decoration and ensure the name ends in _Extension.
Example of Class declaration:
[ExtensionOf(formStr(FormName))]final class
MyFormName_Extension{}
- With extension classes we can add member variables, and
these variables will be associated with the form.
- These variables can be referenced from any instance
method. That way the state of the form can be maintained across different
instance methods.
- Extension classes instantiate automatically; there is no
access to private methods, but we can add state variables and access them along
with forms public variables and methods.
The event handlers can be created as an instance methods.
There are two types of event handler: a pre-event and post-event handler.
- Events are raised as preceding and succeeding operations
around the base methods. We can write code to execute a before-base method
(Pre-Event) or an after-base (Post-Event) method.
·
Copy
event handler method: This option copies a method signature to the clipboard.
You can paste it in any X++ code editor to define a method that subscribes to
the selected event.
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();
}
{
FormRun formRun = sender.formRun() as FormRun;
formRun.myCustomMethod();
}
Please Note: The event handler methods can be
applied to Table level methods (i.e ValidateWrite) same way. Instead of
overriding the methods, you would subscribe to Event Handler Method(s).

Merkur 23C Progress Adjustable Safety Razor - XN
ReplyDeleteShop Merkur 23C Progress Adjustable Safety Razor at XN. The Merkur 23c Progress is the largest and best 샌즈카지노 adjustable 인카지노 safety razor that 메리트 카지노 고객센터 you will find at any