Skip to main content

Notifications

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

  • Mav Profile Picture
    Mav on at
    RE: Modifying switch case logic in COC

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

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,853 Most Valuable Professional on at
    RE: Modifying switch case logic in COC

    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.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,996 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,853 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans