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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

How does the call to CoC is decided when there are multiple CoCs for a method?

(0) ShareShare
ReportReport
Posted on by 15

Hi experts,

I am a newbie in D365. I created 2 CoCs for a table method: Class1,Class2.

pastedimage1628827908010v4.png

pastedimage1628827919081v5.png

When debugged, I found that the call's order is:

1. First base table's method is executed

2. Followed by Class 1 method's logic

3. At last Class 2 method's implementation.

pastedimage1628827941702v6.png

Theoretically, since Class 1 was first created & then Class 2, the call goes in the same way. But, how does D365 decide to execute CoC in Class 1's method first & then Class 2? Is there any mechanism that it follows for this.

Thanks in advance!

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: How does the call to CoC is decided when there are multiple CoCs for a method?

    Hi YellowRose, 

    the execution sequence of different extensions on the same place is not guaranteed, and can be different in any systems. Your extensions should never have any dependency to the execution sequence of other extensions in the same place.

  • Suggested answer
    Joris dG Profile Picture
    17,775 on at
    RE: How does the call to CoC is decided when there are multiple CoCs for a method?

    As mentioned already, the order can never be guaranteed. Although we guarantee that the exact same code (meaning, ALL packages) in two environments will run the same.

    If you own all the code, you should really only have 1 CoC wrapper to avoid headaches and remove the need of dependencies.

    If you don't own the code, you should ALWAYS code with the assumption that your CoC method is not the only CoC method, and that any code could run before or after yours.

    In fact, the standard application could add a new CoC method in any update. So always assume you're not the only one.

  • Suggested answer
    Azeem chisty Profile Picture
    25 on at
    RE: How does the call to CoC is decided when there are multiple CoCs for a method?

    Class extension - Method wrapping and Chain of Command

    A
    bove is the document clearly specifying the how COC works.

    Below is the part of script from the article.

    "When this code is run, the system finds any method that wraps the doSomething method. The system randomly runs one of these methods, such as the doSomething method of the BusinessLogic1_Extension class. When the call to the next doSomething method occurs, the system randomly picks another method in the CoC. If no more wrapped methods exist, the system calls the original implementation."

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,882

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 525 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans