Ok, I guess technically what I want is a STOP command, because yes, my first programming language was BASIC.
Here's the thing. I've got an Automation Rule Flow that already has a few nested IFs.
But I need to flip the logic around, and I really just need to have the whole thing STOP if a condition is met.
I think if I use a standard top-level IF block, that will do the trick, because the way it is worded is:
WHEN: Work item created
IF Parent Key field is not empty
THEN Do the rest of the thing
AND So on
So... no ELSEs yet. I use those later.
But at this point, if Parent Key IS EMPTY, it should just stop, right?
But what I really want to do is add a comment before it stops. :-}
So I was thinking, wait, I know sometimes rules BREAK. Like when a WebRequest fails, etc.
What's the most efficient way to do that?
So I would rewrite the logic above to be:
WHEN: Work item created
IF Parent Key field is emptyTHEN Add comment saying "Parent Key is empty"
AND STOPTHEN Do the rest of the thing
AND So on
Is this feasible? I know it's a hack. I know it's also lazy coding. (I've actually split what was an even gnarlier rule into two separate rules, to give me more nested IFs, and so I might be able to restructure it properly. But ugh. I just need a STOP.)
What do you think @Bill Sheboy - know of any actions that are guaranteed to FAIL? :-}
Hi! The BASIC instinct is totally valid here. 🙂
I wouldn't recommend intentionally making the rule fail. Using a failing action (such as a broken web request) will mark the rule as an error in the audit log, making it much harder to troubleshoot later.
In my opinion a cleaner approach is to structure the rule using an IF / ELSE IF.
For example:
WHEN: Work item created
IF Parent Key is empty
THEN Add comment: "Parent Key is empty"
ELSE IF Parent Key is not empty
THEN Do the rest of the thing
AND So on
With this structure:
ELSE IF branch is not evaluated, so none of the remaining actions are executed.IF is skipped.ELSE IF branch is executed, and the rest of your automation runs as expected.This gives you the "STOP" behavior you're looking for without needing a dedicated stop action or intentionally causing the rule to fail. The rule simply follows the appropriate branch and exits naturally when that branch is complete.
The only thing to watch for is whether the Parent Key has already been populated when the rule runs. If you're triggering on Work item created and that field may be set a moment later, you may need to Re-fetch work item data before checking it. Otherwise, this is a simple and clean way to implement the logic.
Maybe instead of a comment, I would just use the 'Log Action'. Less impact on the ticket and you can test it a bit easier that way.
Another thing to watch out for is if you have another Automation that creates subtasks. You might need to check the box at the bottom of the Automation Rule Flow that states 'Check to allow other rule actions to trigger this rule. Only enable this if you need this rule to execute in response to another rule.' Test without it first and see what happens. Good luck!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.