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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Hookable attribute in ...
Finance forum

Hookable attribute in D365FO

(0) ShareShare
ReportReport
Posted on by 56

Dear All,

I read in some blogs regarding Hookable concept. I not understand the concept properly. I saw some error they posted there.

5123.hooka.jpg

Can you please let me know in brief what is the reason to come this error ? How to resolve this ?

Please give me more shed on this.

Thanks!

I have the same question (0)
  • Verified answer
    Sukrut Parab Profile Picture
    71,741 Moderator on at

    If the method is decorated with hookable attribute you can create pre or post event handler. Some protected methods are decorated with this attribute in standard application that's why you can create pre or post event handler for those methods , if those are not decorated then you can't create pre or post event for those methods, in that case you can use coc.

  • @rp@n Profile Picture
    56 on at

    Thanks Sukrut,

    I almost understand. One thing only. How I will came to know the method those I am going to use that is Hookable? Is there any specific significant mentioned in that hookable method ?

    Please give me more she'd on this

    Thanks!

  • Verified answer
    Sukrut Parab Profile Picture
    71,741 Moderator on at

    You are going to see protected methods like this

    [HookableAttribute(true)]

    protected void loadModule()

    {

    }

  • @rp@n Profile Picture
    56 on at

    Thanks Sukrut

    I beleive public method is already hookable method.

    Suppose the method I am going to use in Event handler i.e Non hookable method .

    Can I make it as Hookable method?

    OR

    Instead of making hookable,  shall I go for COC. I believe COC supports both hookable or Non hookable method.

    Please give me more she'd on this

    Thanks!

  • Verified answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Hi!

    Take a look at this discussion https://community.dynamics.com/ax/f/33/t/218894, maybe it will be helpful.

  • @rp@n Profile Picture
    56 on at

    Thanks Rustem

    Yes I go through the link. I understand almost.

    1. If I wants to do any Non hookable method to Hookable method then only I have to declare

    Hookable Attribute(True)

    Protected void calc()

    2. I already asked Instead of making hookable,  shall I go for COC. I believe COC supports both hookable or Non hookable method.

    Please give me more she'd on this

    Thanks!

  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Yes. But if a method is explicitly marked as Hookable(false), the method can't be wrapped in an extension class.

  • Verified answer
    Sukrut Parab Profile Picture
    71,741 Moderator on at

    Yes you have to use coc now because any standard method you can not change now.

  • Verified answer
    nmaenpaa Profile Picture
    101,172 Moderator on at

    1) You can't do this for the standard methods since that would require overlayering

    2) Just use CoC when you can.

    Hookable was just a way for MS to expose protected methods for event handlers. CoC came later and has mostly replaced event handlers (and will continue to do so with the new CoC capabilities of PU20).

    You will still need event handlers in many cases, mostly on the framework events on forms and tables. But hookable attribute on a protected method is not very important any more.

  • @rp@n Profile Picture
    56 on at

    Thanks everyone

    So, if I got the above error in any methods while using Event handler then I will go for COC instead of making hookable.

    Thanks!

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans