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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Modifying switch case logic in COC

(0) ShareShare
ReportReport
Posted on by

Hello folks,

I have a requirement shared below in code snippets comments beginning with "Aim"

As this is custom requirement ISV as expected has turned down the request to develop custom fix for us. So we are on our own and need to tackle this via COC.

Can you please suggest how can we modify the switch case logic using COC or any other approach.

//ISV Code
public ISVClass1
{
    Common common;
    // Some ISV code and in contruct and new which basically populates common as & when used 
    
    public void isvMethodContainingSwitchCase()
    {
     
     switch (common.TableID)
     {
        case tablenum(Table1):
        this.isvMethod1();
        
        case tablenum(Table2):
        this.isvMethod2();
        
        case tablenum(Table3):
        this.isvMethod3();
    
        case tablenum(TableN):
        this.isvMethodN();
        
    }
    public void isvMethod1()
    {
       //Do something
    }
    
    public void isvMethod2()
    {
       //Do something
    }
    
    public void isvMethod3()
    {
       //Do something
    }
    
    public void isvMethodN()
    {
       //Do something
    }
    
} // END of ISV class

//Begin my COC of above class
//Objective is to not call ISVMethod1() and ISVMethod3() for certain values in table1.customcolumn1 & table3.customcolumn1
[ExtensionOf(classStr(ISVClass1))]
final class myExtensionOfISVClass
{
  //Coc of isvMethodContainingSwitchCase()
  public void isvMethodContainingSwitchCase()
  {
 
    switch (common.TableID)
    {
        case tablenum(Table1):
        Table1 table1 = common;
        if(table1.customcololmn1 == '') // Aim to call this.ISVMethod1() only when there is no value in customColumn1 of table1
        {
            this.isvMethod1();
        }
        case tablenum(Table3):
        Table3 table3 = common;
        if(table3.customcololmn1 == '') // Aim to call this.ISVMethod3() only when there is no value in customColumn1 of 
        {
            this.isvMethod3();
        }
      
    }
     next isvMethodContainingSwitchCase(); // Aim is to call all other switch case condition apart from one above  
    
  }

Thanks

Mav

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    239,035 Most Valuable Professional on at

    What you want isn't possible - extensions don't allow you to change code inside methods. You'll need to look for another design.

    For example, maybe you can somehow influence the bahavior by extending isvMethod1() and isvMethod3(). Maybe you shouldn't call  isvMethodContainingSwitchCase() at all if customcololmn1 isn't empty. Maybe you need to ask the ISV to add an extension point.

    A hack may be providing a record of a different table if customcololmn1 isn't empty, but it could easily lead to errors at other places.

  • Mav Profile Picture
    on at

    Looks like I should be able to use Idispose in meeting the above requirement

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 659

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 465 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 304 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans