Monday, July 22, 2019

Event Handlers

In Dynamics 365 F&O we are not allowed to add our custom logic in between the core logic but we can execute our custom logic before and after the core logic and this can be achieved by using the Event handlers.
Microsoft® recommends usage of event handlers in every possible place because it is the best and safest way to customize any existing functionality to accommodate user requirements.

The are two types of Event Handlers

Pre-Event Handler    (Executed before the core logic)

Post-Event Handler   (Executed after the core logic)


You can use Event Handler for following elements

1) Tables
2) Classes
3) Forms

Examples of Pre-Event Handler:

Let’s take an example of table "LedgerJournalTrans" it has a method of "Insert" and we want to verify the value of field "AmountCurCredit" that it should not be greater than 3000.

So here we can use the pre event handler which will be executed before the core insert method.
You can use the Pre-Event Handler for following purposes
1) Validation
2) update value
3) Assign values etc..

click here for more detail about "Creating a Pre-Event Handler"

Example of Post-Event Handler:

Let’s take the same example as above but here we just need to warn the user after the record is "Inserted" so we use the post event handler which throws the warning that the limit is exceeded.
So here we can use the Post Event Handler.

You can use the Post-Event Handler for following purposes
1) Update Values
2) Warnings etc..

click here for more details about "Creating a Post Event Handler"






Post Event Handler

In Dynamics 365 F&O we are not allowed to add our custom logic in between the  core logic  but we can execute our custom logic before ...