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

Notifications

Announcements

Community site session details

Community site session details

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

Condition put in CoC in D365FO

(2) ShareShare
ReportReport
Posted on by 88
Dear team,
 
Can we put condition in CoC? I mean if condition is true then only CoC will execute else not 
 
If not possible then if any workaround is there?
 
Please give me the thoughts. thanks!
Categories:
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    238,145 Most Valuable Professional on at
    No, it's not possible. CoC means that you create an extension class and extend a method; there is no way how to make the existence of a class or a method conditional. It's either there or not.
     
    But you can put conditions to the method code.
     
    Maybe you mean whether you can conditionally call the base method (with the next keyword). It's not normally possible, unless the base method is explicitly marked as replaceable.
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,592 Super User 2025 Season 2 on at
     
    It is not recommended to ignore the call to next, but you can do so with an exception !
     
    Best regards,
  • CU10121822-0 Profile Picture
    88 on at
    Hi, I tried in below way:
     
    [ExtensionOf(classStr(SalesTable))]
    final class SalesTable_Extension
    {
        public void update()
        {
            try
            {
                // Pre-logic with condition
                if (this.CustAccount == 'CUST001')
                {
                    info("Before update: Special customer logic");
                }
                
                next update();
    
                // Post-logic with condition
                if (this.SalesStatus == SalesStatus::Invoiced)
                {
                    info("After update: Sales order invoiced");
                }
            }
            catch (Exception::Error)
            {
                error("Error occurred while updating SalesTable");
                throw; // always rethrow in CoC
            }
        }
    }
     
    So, here what I understood, the condition is returned TRUE or False, it's doesn't matter, CoC will execute always.
     
    am I correct?

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

News and Announcements

Season of Giving Solutions is Here!

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
Abhilash Warrier Profile Picture

Abhilash Warrier 732 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 289 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans