SBX - Search With Button

SBX - Forum Post Title

what is the difference between method and event in table in D365FO.

Microsoft Dynamics AX Forum

@rp@n asked a question on 12 Jul 2018 5:29 PM
My Badges

Question Status

Suggested Answer

Dear all,

Can you please let me know what is the difference between method and event in table  in D365FO.

Kindly give me an real time example.

Please give me more shed on this.

Thanks!

Reply
Rustem Galiamov responded on 12 Jul 2018 5:58 PM
My Badges
Boris Diroo responded on 16 Jul 2018 11:34 AM
My Badges
Suggested Answer

Hello @rp@n,

This docs.microsoft.com/.../customization-overlayering-extensions article explains Events are raised as preceding and succeeding operations around the base methods. This means that you have the opportunity to run code before a base method is called and after it has completed. Microsoft Dynamics AX 2012 introduced XPP events, which are also available in this release and can be subscribed to in your extensions. have a look at the full article that might help understand.

Hope this helps!

Reply
Ada Ding responded on 16 Jul 2018 8:08 PM
My Badges

Hi,

Event handlers can be used to fire up our code without the necessary to customize and interfere on core logic and elements.

Look at the following example:

We create a new field in InventJournalTrans.Extension that extends the base package element InventJournalTrans table. We copy the event handler of the method on ModifiedField and copy it in our custom class.

[DataEventHandler(tableStr(InventJournalTrans), DataEventType::ModifiedField)]

public static void InventJournalTrans_onModifiedField (Common sender, DataEventArgs e)

The DataEventHandler specifies the source of the event (the table InventJournalTrans) and DataEventType is an enum for the type of event supported. Once the event arguments are received, we get field ID to call our logic.

In summary, a table method contains the business logic that is related to a table. We usually encapsulate actions in methods on the table to keep our code clean.

While an event is used to customize our application code without overlayering the base package application objects.

Reply
Boris Diroo responded on 16 Jul 2018 11:34 AM
My Badges
Suggested Answer

Hello @rp@n,

This docs.microsoft.com/.../customization-overlayering-extensions article explains Events are raised as preceding and succeeding operations around the base methods. This means that you have the opportunity to run code before a base method is called and after it has completed. Microsoft Dynamics AX 2012 introduced XPP events, which are also available in this release and can be subscribed to in your extensions. have a look at the full article that might help understand.

Hope this helps!

Reply

SBX - Two Col Forum

SBX - Migrated JS