Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / CoC with method whose ...
Finance forum
Suggested answer

CoC with method whose signature includes default values

Posted on by Microsoft Employee

how can I use CoC with method whose signature includes default values , CoC  signature  does not accept default and method itself may be called with number of parameters less than defined in CoC signature ?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CoC with method whose signature includes default values

    Hi Sanjay kumar singh,

    As per my comment just above , I tried what you shared but it does not work with me

  • Sanjay kumar singh Profile Picture
    Sanjay kumar singh 240 on at
    RE: CoC with method whose signature includes default values

    DefaultValue.pngPlease go through,

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CoC with method whose signature includes default values

    I try to use CoC for static method PayrollPayStatementBenefitLine::create to add some extra logic

    I add all parameters in CoC method signature  and I can build the model successfully

    when I run generate pay statement, the execution is interrupted  

    when I check the standard  calling of this method I find that it is called some times with number of input parameter less than that in CoC signature

  • Sukrut Parab Profile Picture
    Sukrut Parab 71,645 Moderator on at
    RE: CoC with method whose signature includes default values

    You can still get the default values from the same parameters which are in the method signature.

  • Eugen Glasow Profile Picture
    Eugen Glasow 6,351 on at
    RE: CoC with method whose signature includes default values

    CoC = Chain of Command. In an extended method you just omit the defaulting in the parameters:

    void doSomethingWithTheItem(ItemId _itemId = itemId) becomes

    void doSomethingWithTheItem(ItemId _itemId) in an extension, but the ability to get a default value remains.

    This is the basics.

  • Ludwig Reinhard Profile Picture
    Ludwig Reinhard Microsoft Employee on at
    RE: CoC with method whose signature includes default values

    Hi,

    Can you please elaborat what you try to achieve and write the complete text of your abbreviation at least once?

    Many thanks,

    Ludwig

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: CoC with method whose signature includes default values

    Please check the documentation: [View:https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/extensibility/method-wrapping-coc#what-about-default-parameters:750:50]

    Methods that have default parameters can be wrapped by extension classes. However, the method signature in the wrapper method must not include the default value of the parameter.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,252 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,089 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans