"Break" Function to simplify triggers

Hey everyone, a quick trick I just learned myself!

When you have multiple triggers tied to one action, they execute in order until one trigger has a transition fire.

image

There are times where you want to use multiple triggers, but only execute earlier triggers given certain criteria. A common example is field validation for buttons which process data being inputted. Before learning this trick, I would use a “Can proceed” variable to control my triggers when I use multiple such as this trigger in “Show 1”

Then, inside of “Show 2” and “Show 3”, I would use a conditional statement to determine if I still needed to run that trigger.

image

However, a much simpler solution when you need to “break” from a group of triggers is to simply route to the current step. This will prevent all following triggers from executing, and there will be no noticeable difference to the user.

image

This trigger will end the string of triggers after showing message 1. No variables or additional triggers to worry about!

It is very valuable to separate triggers. This is a neat little trick which can make them slimmer and easier to understand!

3 Likes

You have two solutions for a problem I was struggling with. Thank you sir! Its a great to be alive!

:grinning:

2 Likes

Nice solution, but this has the following disadvantage for my use cases:
If you have any step enter trigger you need to check the behavior of these carefully. So I often use the step enter trigger to clear all fields and reset important variables. Not so good :wink:

2cents
Chris

Exactly… that’s why I mostly use a boolean variable, that i set to true at the beginning and any trigger will flip it false, if something goes wrong.
This variable also is a condition for any trigger to execute…

I know that’s not as easy as reloading the step, but it is clear to understand and flexible (you could still select which triggers to fire or not etc…)

1 Like

This has been a product gap for way too long. I use both of these strategies quite often and it confuses many less experienced Tulip developers who I am either working with or training.