One condition, many actions

So, I have a question about best practice(s).

While setting up a custom validation for forms, I constantly find myself using two actions in a workflow:

  1. Display an alert only if a condition is true (e.g. some options selected cannot be combined so you can’t save)
  2. Terminate this workflow if the previous condition is true

To do that, the condition is checked twice (once at each step) and this seems to me inefficient in every way.

Is that correct? Is this how it should be done or am I obviously doing something wrong?

Is there a way to check a condition and, if true, perform both actions?

Thanks in advance

Hi @nassosk
It depends if you check with a condition need loading data each time it will be bad for workload and performance
so to avoid this situation you have to set state to save your status yes , no or whatever you want and use state as you like for more than one step to check with state .

1 Like

Better to use a text custom state to store the validation message so as to kill 2 birds with one stone and not have to maintain 2 sets of conditionals (one for the boolean if valid or not and another for the messaging based on invalid reason)


Thanks, both.

I am not sure I understand your responses though, because the question is not about checking the condition (I know how to do this once on page level) but doing two things when the condition is true.

  1. Display message, if true
  2. Stop running, if true

See what I mean?

Why not utilise custom events for this?

Or use two workflow events instead of one.

1 Like

They understand what you are saying, and their proposed solution works great.
Having two actions is not a problem, they are very light actions anyways. Don’t see it as a negative. However checking the same conditional multiple times could be a problem if its a heavy conditional that uses a search or a lot of data. It is also harder to maintain, as the conditional is in many different places.

Setting a custom state to ‘yes’, and then using that custom state in both conditionals is a very good solution to fix both these issues. Checking if a custom state is true or false is an extremely light client-side action, so dont worry about it affecting performance or efficiency.