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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

How will used private method in CoC

(3) ShareShare
ReportReport
Posted on by
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
    239,029 Most Valuable Professional on at
    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
    on at
    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
    239,029 Most Valuable Professional on at
    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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans