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

Can a CoC overwrite a standard method ?

(0) ShareShare
ReportReport
Posted on by 596

Hi guys,

In a standard table, usually there is a ValidateWrite() method. Can we create CoC on this method and overwrite it ? or in other words is "overidden" some condition in the existing method. 

Thanks

I have the same question (0)
  • Suggested answer
    Komi Siabi Profile Picture
    13,228 Most Valuable Professional on at

    Hello,

    You can not override a standard method but you can extend it. What you actually do with the CoC is either, you let Microsoft code run first then, yours run after, or you run yours first then, the standard's.

    Which ever way, the standard code must run.

  • Suggested answer
    Mohit Rampal Profile Picture
    12,573 Moderator on at

    Hi, You can bypass standard logic by manipulating some code but its not always possible. By override, if you mean to suprress call to standard method then its not possible. If you have a requirement, please share so we can try to help.

  • Voltes Profile Picture
    596 on at

    Hi both,

    Thanks, yes I have a requirement to suppress the validateWrite for throwing error, replace by Warning only on this part in table RevRecDeferredLine 

    public boolean validateWrite()
        {
            boolean ret;
        
            if (this.RecognizeAmount >= 0 && (this.RemainingAmount > this.RecognizeAmount))
            {
                //Revenue to release is greater than remaining revenue to recognize
                return checkFailed("@RevenueRecognition:RevenueToReleaseGreaterThanRemainingRevenueToRecognize");
            }
        
            if (this.RecognizeAmount < 0 && (this.RecognizeNowAmount < this.RecognizeAmount))
            {
                //Revenue to release is less than remaining revenue to recognize
                return checkfailed("@RevenueRecognition:RevenueToReleaseLessThanRemainingRevenueToRecognize");
            }
    }

    It has other condition, but I only need to change this to warning only instead checkfailed. Is it possible in CoC ?

    Thanks

  • Suggested answer
    Mohit Rampal Profile Picture
    12,573 Moderator on at

    Hi, You can try doing it like this code so it bypass standard code and then you can throw warning instead of error.

    public boolean validateWrite()
    {
    Amount RemainingAmountLocal, RecognizeAmountLocal;
    
    RemainingAmountLocal = this.RemainingAmount;
    RecognizeAmountLocal = this.RecognizeAmount;
    
    this.RemainingAmount = 0;
    this.RecognizeAmount = 0;
    
    boolean ret = next validateWrite();
    
    this.RemainingAmount = RemainingAmountLocal;
    this.RecognizeAmount = RecognizeAmountLocal;   
            
    if (this.RecognizeAmount >= 0 && (this.RemainingAmount > this.RecognizeAmount))
    {
       //Revenue to release is greater than remaining revenue to recognize
       warning("@RevenueRecognition:RevenueToReleaseGreaterThanRemainingRevenueToRecognize");
    }
        
    if (this.RecognizeAmount < 0 && (this.RecognizeNowAmount < this.RecognizeAmount))
    {
        //Revenue to release is less than remaining revenue to recognize
        warning("@RevenueRecognition:RevenueToReleaseLessThanRemainingRevenueToRecognize");
    }
            
    return ret;
    }

  • Martin Dráb Profile Picture
    239,392 Most Valuable Professional on at

    It doesn't throw an error. Calling checkFailed("x") does exactly the same thing as warning("x"). The difference is elsewhere - in the return statement. return checkFailed("x") is an equivalent of this:

    warning("x");
    return false;

    Therefore you would like to keep the warning (no need to call it again) and return true instead of false. But... you should change the return value only if it failed on these particular conditions and no other.

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 689

#2
André Arnaud de Calavon Profile Picture

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

#3
CP04-islander Profile Picture

CP04-islander 356

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans