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

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
    237,801 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

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