Skip to main content
Post a question

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Can a CoC overwrite a standard method ?

Like (0) ShareShare
ReportReport
Posted on 12 Apr 2023 11:49:09 by 592

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

  • Martin Dráb Profile Picture
    231,723 Most Valuable Professional on 12 Apr 2023 at 12:18:53
    RE: Can a CoC overwrite a standard method ?

    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.

  • Suggested answer
    Mohit Rampal Profile Picture
    12,554 Moderator on 12 Apr 2023 at 12:13:22
    RE: Can a CoC overwrite a standard method ?

    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;
    }

  • Voltes Profile Picture
    592 on 12 Apr 2023 at 12:06:21
    RE: Can a CoC overwrite a standard method ?

    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,554 Moderator on 12 Apr 2023 at 11:55:01
    RE: Can a CoC overwrite a standard method ?

    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.

  • Suggested answer
    Komi Siabi Profile Picture
    12,772 Most Valuable Professional on 12 Apr 2023 at 11:54:13
    RE: Can a CoC overwrite a standard method ?

    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.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,850 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,723 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans
Loading complete