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

If a condition fails - How to stop the flow and throw an error

(1) ShareShare
ReportReport
Posted on by 204

Hi,
I have a requirement where, on a clicked method, i have an if condition applied and if the condition is true, it should stop the flow and just show the error message. 

The code used was : Throw error("The condition failed");  

After debugging, it is going in the if condition and also it is successfully displaying the error, but it is not stopping the flow. The action is being executed. I want to stop the flow/Action from being executed. 
Is there any other command I should be using?

I have the same question (0)
  • Anton Venter Profile Picture
    20,346 Super User 2025 Season 2 on at

    Hi,

    Please share more info/screenshots on this so that we can see what's going on. Using the "throw error" statement usually stop the process flow but there could be valid reasons why it's continueing. E.g. check if the code is within error handling (try.. catch statement), or perhaps it's within nested error handling.

    X++ exception handling

    learn.microsoft.com/.../xpp-exceptions

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    Just put your logic when the error doesn't occur. I mean in if check if it is success and write your logic and in else write failing logic like throw error. So if it fails then it will throw error.

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... 456 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 429 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans