Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

Can a CoC overwrite a standard method ?

(0) ShareShare
ReportReport
Posted on 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
    Martin Dráb 230,853 Most Valuable Professional on at
    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
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    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
    Voltes 592 on at
    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
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    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
    Komi Siabi 12,759 Most Valuable Professional on at
    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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,996 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,853 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans