01 Apr 2025 05:52 PM
I am trying to create a work flow where I will send an email based on the results of the the previous step. In this case I have a value in the result; if the value is > x, send email, of not move to the next.
Problem I am having is as soon as the value is not met the entire task stops. Is there anyway to combine the loop option with the custom condition?
example of the Custom Condition:
{{ result("get_slo_result")[0].SLO_Results["Value"] >= 0.05 }}
Solved! Go to Solution.
02 Apr 2025 07:34 AM
On the task with the custom condition, you have to define the "Stop" behaviour as "Skip":
After that, the Workflow should continue with the next task:
02 Apr 2025 01:26 PM
Right, but I am not looking for a next step. The results from the step before contains the Value I am looking to judge if > 0.5 send the email, if not move to the next item, not another task. If I have a list of 100 items, and the first 5 require an email and the next item doesn't the task stops and doesn't look at the next item. I want it to move to the next item.
If I do have a next step, will the next item in the list be evaluated? Use this task more or less as a decision point?
07 Apr 2025 09:02 AM
So I'm assuming when you say next item, you don't mean the next task in the workflow as Christian understood, but rather you have a list that you want to iterate through and only send an email for the ones that have .SLO_Results["Value"] >= 0.05.
In that case, you have to think about it a bit differently. Instead of looping through everything and then having a condition, you rather genrate a list that contains only those that you want to send the email for and the loop over those (or simply send one email with the list of recipients if it is always the same content).
This can be achieved in two ways:
1) if you don't need to other information later on, the simplest / most efficient solution would be to filter already in the inital task. If this is fore example a DQL query, you would add the filter statement there already.
2) if this is not possible / you need the other data in some other task, you can also generate the new list using expressions. The selectattr (Template Designer Documentation — Jinja Documentation (3.1.x)) allows you to filter a list of objects based off of its attributes values. In your case, this would be this:
{{ result("get_slo_result") | selectattr("SLO_Results.Value", ">=", 0.05) | list }}
You can now either put this into the loop option of the email task, which will iterate over this new, filtered list and send an email for each, or you can extract the email addresses all into a single list and send one email to all instead of doing the loop and just putting it directly into the to field, like so (in my example I have an email address in the "email" attribute:
{{ result("get_slo_result") | selectattr("SLO_Results.Value", ">=", 0.05) | map(attribute="email") | list }}
07 Apr 2025 02:01 PM
This was exactly what I needed; GREATLY appreciate the assistance.