web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Table - Method / Events in d365fo

(0) ShareShare
ReportReport
Posted on by 30

Hi team,

I have little confusion between Application Explorer -- Table - Methods & Events

For example -  Cust Table- ModifiedField

PIC 1 -Method - 

5468.a1.jpg

Pic 2 Events - 

pastedimage1678855694608v1.png

OnModifiedField - (Post Event)

OnModifyingField - (Pre Event)

Kindly let me know is both (Pic1 & Pic2) are same? Only the approaches are different?

If required, Shall I use anyone of them?

Please give me more shed on this.

thanks!

I have the same question (0)
  • Verified answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    Here to write/use a method in code we basically have 2 approaches. One by event handlers and two by coc.

    Both the ways will give you same result. But based on their framework the capability varies. Like for example in coc you can extend protected method write some custom code or call a new method. For eventhandlers, they cannot access protected methods. The way we write pre coc and post coc, similarly eventhandlers.

    But in code execution the coc override the event handlers. Means first the event handler then coc will execute.

  • Verified answer
    GirishS Profile Picture
    27,827 Moderator on at

    Hi,

    Both works similarly. But the second one is mainly used for the custom methods where you want to override the post and pre-event handler method.

    For example, let's say from the screenshot we have standard method birthdate - We need to customize this method - In that case you can go for Pic 1 where you can write pre and post event handlers.

    Pic 2 will be mainly for in Built standard override methods where Microsoft has already provided event handler like onModifiedField and On Modifying field which is similar to post and pre-event handler.

    Thanks,

    Girish S.

  • @rp@n Profile Picture
    30 on at

    Thanks Bharani,

    What I understand, If I used Event Handlers or Pre CoC/ Post CoC both are return the same result.

    The only thing is

    With use of Event handlers, we can not use Protected method, Only Private and Public method can use.

    With CoC (Pre CoC/ Post CoC),  we can use Public, Private and Protected method  .

    Am I right?

    Please give me more shed on this.

    thanks!

  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi, I think its basically about placement of your code in a method. Sequence is Pre-Event Handlers are called first, then particular method will be executed. Before call to super, Pre Events are called, after super Post Events are called and in last Post Event Handlers

    Pre-Insert (Pre-Event Handler)

    OnInserting (Pre-Event)

    super ()

    OnInserted (Post-Event)

    Post-Insert (Post-Event Handler)

  • Verified answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    No it's wrong. Private method can be accessed only from that class not from extension like coc or event handler.

    Event handler supports public method and coc supports both public and protected methods.

    Also you can try the same thing in vs so that you can get clear understanding.

  • @rp@n Profile Picture
    30 on at

    Thanks Bharani

  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    Event handlers supports public method, but Private and protected methods can also be accessed from event handlers if there is a hookable attribute is set to true on that method identifier.

    [Hookable(true}]
    private void methodName()
    {
    }

    Since the methodName has hookable attribute set to true you can write event handler for that method.

    Thanks,

    Girish S.

  • @rp@n Profile Picture
    30 on at

    Thanks Girish for the update

    Suppose the hookable is set to false and if required to set hookable to true. then we need to contact MS or we can directly change by myself ?

    pls give me more shed on this

  • GirishS Profile Picture
    27,827 Moderator on at

    No, you cannot change that directly - You need to contact MS.

    Thanks,

    Girish S.

  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    Understood Girish. Thank you.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans