# How to compose a condition with an if statement in workflows

**URL:** <https://community.dynatrace.com/t/how-to-compose-a-condition-with-an-if-statement-in-workflows/47334>\
**Category:** Automations\
**Tags:** workflows, automations\
**Created:** [August 27, 2024, 7:57am UTC](https://community.dynatrace.com/t/how-to-compose-a-condition-with-an-if-statement-in-workflows/47334 "2024-08-27T07:57:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wouterdt](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/wouterdt/32/25147_2.png) [@wouterdt](https://community.dynatrace.com/u/wouterdt)\
**Post date:** [August 27, 2024, 7:57am UTC](https://community.dynatrace.com/t/how-to-compose-a-condition-with-an-if-statement-in-workflows/47334/1 "2024-08-27T07:57:21Z")

</div>

Hi

i’m trying to figure out how the if statements work in conditions in workflows using this doc  
&nbsp;[https://docs.dynatrace.com/docs/platform-modules/automations/workflows/reference#if-statement](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?

---

<div class="post-metadata">

**Author:** ![Eric\_Yu](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/eric_yu/32/20360_2.png) [@Eric\_Yu](https://community.dynatrace.com/u/Eric_Yu)\
**Post date:** [August 27, 2024, 9:58pm UTC](https://community.dynatrace.com/t/how-to-compose-a-condition-with-an-if-statement-in-workflows/47334/2 "2024-08-27T21:58:21Z")

</div>

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:

 ![Eric_Yu_0-1724795865894.png](https://global.discourse-cdn.com/dynatrace/original/3X/e/5/e5272af808b97f8b0c526c26b29a57148f75df9c.png)

---

<div class="post-metadata">

**Author:** ![wouterdt](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/wouterdt/32/25147_2.png) [@wouterdt](https://community.dynatrace.com/u/wouterdt)\
**Post date:** [August 28, 2024, 5:51am UTC](https://community.dynatrace.com/t/how-to-compose-a-condition-with-an-if-statement-in-workflows/47334/3 "2024-08-28T05:51:45Z")

</div>

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&nbsp; 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 %}

---

<div class="post-metadata">

**Author:** ![ChristopherHejl](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/christopherhejl/32/20735_2.png) [@ChristopherHejl](https://community.dynatrace.com/u/ChristopherHejl)\
**Post date:** [September 2, 2024, 12:19pm UTC](https://community.dynatrace.com/t/how-to-compose-a-condition-with-an-if-statement-in-workflows/47334/4 "2024-09-02T12:19:36Z")

</div>

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)](https://jinja.palletsprojects.com/en/3.0.x/templates/#logic)  
example:

```python
{{ result('action1').production == true and result('action2').priority == "P1" }}

```
