Skip to main content

Notifications

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 202

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?

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,624 Moderator on at
    RE: If a condition fails - How to stop the flow and throw an error

    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.

  • Anton Venter Profile Picture
    19,593 Super User 2025 Season 1 on at
    RE: If a condition fails - How to stop the flow and throw an error

    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

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March 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... 294,060 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,858 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans