27 Aug 2024 08:57 AM
Hi
i'm trying to figure out how the if statements work in conditions in workflows using this doc
https://docs.dynatrace.com/docs/platform-modules/automations/workflows/reference#if-statement
I have a 3rd actions that should only fire when a value from the first actions and one from the seccond action equal a string.
I started off by just trying an if for the first action, but it never seems to trigger.
{%if result('action1').production == true %}
{% endif %}
a more simple version does work
{{result('action1').production == true}}
how do yo format that if statement?
does anyone have an example?
Solved! Go to Solution.
27 Aug 2024 10:58 PM
If your value is already a boolean, I don't think you need to use the "== true" part. Also make sure your result is being returned in the previous step.
Something like this should work:
28 Aug 2024 06:51 AM
Currently it runs with the {{ variable == true }} without issue so you can use the true part
question is on on how to introduce a second variable and only proceed when 2 variables match a condition.
The Jinja2 doc talks about if statements but i don't understand how to introduce them in this context.
The Dynatrace doc mentions if as well but does not show an example.
Tried stuff like this without much luck
{%if result('action1').production == true %}
{%if result('action2').priority == "P1" %}
{% endif %}
{% endif %}
02 Sep 2024 01:19 PM
The custom condition field is essentially already wrapped in an "if" statement and you only provide the condition, as the action and else block are predefined.
As for combining multiple conditions, you'd use and, or and brackets () if needed.
Template Designer Documentation — Jinja Documentation (3.0.x) (palletsprojects.com)
example:
{{ result('action1').production == true and result('action2').priority == "P1" }}