Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

Detecting default parameters when calling next method in extension classes.

(1) ShareShare
ReportReport
Posted on by 87
Hello,
 
I have a technical issue that i think is important for a correct standard code preservation.
 
Let's say i have an standard class:
 
public class A
{
     public ExampleEDT test(String _a, String _b, boolean _c=false, boolean _d=false)
     {
          ExampleEDT      ret;
          if(primisDefault(_c) && primisDefault(_d))
          {
               //some if code
          }
          else
          {
               //some else code
          }
          
          return ret;
     }
}
 
Then i create a test() method extension:
 
[ExtensionOf(classStr(A))]
public class A_Extension
{
     public ExampleEDT test(String _a, String _b, boolean _c, boolean _d)
     {
          ExampleEDT ret;
         
          ret = next test(_a,_b,_c,_d);          
 
          return ret;
     }
}
 
 
I detected that, even when initially i call the test method 'a.test(string1, string2)' without using the extension, the standard code works as expected entering the first 'if', detecting _c and _d parameters as default. BUT, when using the extension it doesn't detect as default parameters. so the logic on the standard method doesn't work properly. (entering in the else part). The problem I see, is that I must call the next method using all the parameters (not only the mandatory) otherwise i get a runtime error.
 
In some cases, i can resolve this situation bringing the standard method logic to the extension's method, but in my opinion this is a bad practice since i am ignoring the standard code (and future changes).
 
 
I would like to know if there is any way to preserve the @_isDefaultSet property between extensions and standard classes
 
 
Thanks in advance,
Eisenberk.
 

 
  • Basti Aurand Profile Picture
    Basti Aurand 115 on at
    Detecting default parameters when calling next method in extension classes.
    I also faced this issue today. So it's still existing. No bugfixing from MS as far as I experienced. Is there any solution or is this just by design and we will have to do some workaround. What could be a workaround?
     
    I would realy appreciate any hints on this
  • Layan Jwei Profile Picture
    Layan Jwei 7,264 Super User 2024 Season 2 on at
    Detecting default parameters when calling next method in extension classes.
    Hi Eisenberk,

    I tried it now and faced the same thing. Maybe it's a bug that needs raising with Microsoft.
     
    Thanks,
    Layan Jweihan
    Please mark the answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,642 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans