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

Community site session details

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

How will used private method in CoC

(0) ShareShare
ReportReport
Posted on by 30
Hello,
 
In SalesInvoiceJournalPost class, there is a method "UpdateSalesTableSettleVoucher". As per our requirement, I need to add some piece of code in this method. As I know, CoC is not supported the private method to modify.
 
Kindly advise me the best approach to modify the private method.
 
private void updateSalesTableSettleVoucher(SalesIdBase _salesId, SettlementType _fromSettlementType, SettlementType _toSettlementType)
    {
        SalesTable salesTableUpdate;

        update_recordset salesTableUpdate
            setting SettleVoucher = _toSettlementType
            where salesTableUpdate.SalesId == _salesId &&
                  salesTableUpdate.SettleVoucher == _fromSettlementType;
    }
thanks!
Categories:
I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,306 Most Valuable Professional on at
    How will used private method in CoC
    Neither modifying nor extending a private method is possible. Either you design a solution in a way that can be done, or you need to ask Microsoft to make the method extensible.
     
    Maybe you could implement your logic in endLines() (which can be extended).
  • CU22111441-0 Profile Picture
    30 on at
    How will used private method in CoC
    Thanks Martin for the prompt response.
     
    Yeah , the two approaches for the private method for CoC we can apply.
     
    And additional one more approach which I think, Obviously not for this example. In general based on below scenario...
     
    Suppose I faced the same issue (private method) for some other classes.
     
    For example -
     
    Private getSalesQty()
    {
       // Codes
    }
    
    Public sales total()
    {
       Private getSalesQty()
       {
          // Codes
       }
    }
    Here the private method getSalesQty is called by the Public method salesTotal in the same class.
     
    So, here if we made CoC of public method salesTotal() and after next salesTotal() , if i add the my custom code. 
     
    Here when next salesTotal () executed, it will internally call the private method as well. Then it will execute my custom code.
     
    Is it good approach? 
  • Verified answer
    Martin Dráb Profile Picture
    237,306 Most Valuable Professional on at
    How will used private method in CoC
    It's technically possible. You said it obviously can't be used in your case, but it can. You could extend  endLines() instead of updateSalesTableSettleVoucher(), as I already mention above.     
      
    But it doesn't mean that you can use it every time. It depends on code of the standard methods, as well as on what kind of change you want to make.

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 694 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 635 Super User 2025 Season 2

#3
CU05031448-0 Profile Picture

CU05031448-0 576

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans