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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Chain of Command methods that contain error throws

(0) ShareShare
ReportReport
Posted on by 87

Hello,

I am quite new on D365FO, I am still learning all the ChainOfCommand process.

I extended a standard class which i have to modify the main() method.

//main method in the standard class
public static void main(Args _args)
{
    //Some code
    
    if(....)
    {
        throw error("Error message");
    }
}

So, i extend the main method in the extended class. My problem is that after "next main(null)" there is the possibility that the previous error message is thrown, which i want want to ignore because i am implementing the logic on the extended method

So, i got the idea of doing some try/catch on the extended method.

//Extended method
public static void main(Args _args)
{
    //some code
    
    try
    {
        next main(null)
    }
    catch (Exception::Error)
    {
        continue;
    }
    
    //custom code

Buut, this is not totally correct because i only want to ignore the error thrown in the main method, not other system errors.

Is there any way to achieve my goal?

Thanks in advance,

Eisenberk

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    Hi Eisenberk,

    I think Chain of command won't work here. It will be better to create new class and change all the places where it was used and add the logic as you wish to replace the error.

    COC will call the standard method and then it will run your custom logic. So, both logics will get caller and it's not possible to the bypass the error.

    Thanks,

    Girish S.

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

    Hi, To avoid error written in main class, before calling next Main() in your CoC class, you can manipulate condition written in If loop so if fails the condition and don't go into if condition.

    Please note that it's not always possible to manipulate or by pass standard code.

  • Eisenberk Profile Picture
    87 on at

    I thought it was possible to avoid the throw error chain by catching it, but it seems is not possible.

    I will reevaluate the solution, thanks.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 422 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans