# How can I use ex.result(:xxxxx") with multiple pre-tasks

**URL:** <https://community.dynatrace.com/t/how-can-i-use-ex-result-xxxxx-with-multiple-pre-tasks/46414>\
**Category:** Automations\
**Tags:** workflows, automations\
**Created:** [July 2, 2024, 12:07pm UTC](https://community.dynatrace.com/t/how-can-i-use-ex-result-xxxxx-with-multiple-pre-tasks/46414 "2024-07-02T12:07:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![henk\_stobbe](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/henk_stobbe/32/30434_2.png) [@henk\_stobbe](https://community.dynatrace.com/u/henk_stobbe)\
**Post date:** [July 2, 2024, 12:07pm UTC](https://community.dynatrace.com/t/how-can-i-use-ex-result-xxxxx-with-multiple-pre-tasks/46414/1 "2024-07-02T12:07:21Z")

</div>

Hello workflow fans!&nbsp;&nbsp;😀

I have a task that can be triggered by&nbsp; two predecessors.

I want to use there result in this task. Is there a decent way to do this?

Or do I need to a “if empty then the other on”?

KR Henk

---

<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:** [July 2, 2024, 12:18pm UTC](https://community.dynatrace.com/t/how-can-i-use-ex-result-xxxxx-with-multiple-pre-tasks/46414/2 "2024-07-02T12:18:44Z")

</div>

Hi Henk,

a more detailed example would help to better answer the question, I’ll try my best with some assumptions:  
A task can have multiple predecessors. In order to add dependencies (the lines in the graph) you can click and hold the (+) icon and drag it onto the task you want to draw the line:

 ![ChristopherHejl_0-1719922475815.png](https://global.discourse-cdn.com/dynatrace/original/3X/0/e/0eca24223d4a1dd3a9073e1be881330b1c70d1d6.png)

In this case, task\_3 only runs once both task\_1 and task\_2 are finished.  
Task\_3 then has access to both of their results as normal:

 ![ChristopherHejl_1-1719922521670.png](https://global.discourse-cdn.com/dynatrace/original/3X/b/3/b3792c0eca1030d0baf707ed3155b6dfe146628c.png)

 ![ChristopherHejl_2-1719922530977.png](https://global.discourse-cdn.com/dynatrace/original/2X/d/d75fe4abd2580bd054227616f05a04a45b32a67f.png)

If however task\_1 and/or task\_2 might fail, and you still want to run task\_3, then you have to adapt the conditions of task\_3 accordingly (eg to any state, the color of the lines will change between red, green and black to indicate the dependency):

 ![ChristopherHejl_3-1719922616179.png](https://global.discourse-cdn.com/dynatrace/original/3X/a/e/ae9dc5e82f1872e1af9b9c66b6a054435f2918f9.png)

In this case, task\_3 might run even though task\_2 or task\_1 or both failed and don’t provide a result. You can use tools like if ([Jinja expressions for Workflows — Dynatrace Docs](https://docs.dynatrace.com/docs/platform-modules/automations/workflows/reference#if-statement)) or default filter ([Jinja expressions for Workflows — Dynatrace Docs](https://docs.dynatrace.com/docs/platform-modules/automations/workflows/reference#filters))

---

<div class="post-metadata">

**Author:** ![henk\_stobbe](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/henk_stobbe/32/30434_2.png) [@henk\_stobbe](https://community.dynatrace.com/u/henk_stobbe)\
**Post date:** [July 2, 2024, 12:36pm UTC](https://community.dynatrace.com/t/how-can-i-use-ex-result-xxxxx-with-multiple-pre-tasks/46414/3 "2024-07-02T12:36:20Z")

</div>

Hi Christopher,

You are doing an excellent job! Sorry my question are sometime a little vague. Above already helps a lot, thanks!

To make above complete, suppose you have control over 1 and 2, so only one gets run and the other is skipped.

II suppose in step 3 you have to “try” to retrieve the return of 1 and 2?

Or am I trying something stupid?

Use case: you have green and a blauw events. You send green to 1 and blauw to 2. Then&nbsp; 3 will finish. 3 needs the result of 1 or 2 to proceed.

KR Henk

---

<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:** [July 2, 2024, 1:05pm UTC](https://community.dynatrace.com/t/how-can-i-use-ex-result-xxxxx-with-multiple-pre-tasks/46414/4 "2024-07-02T13:05:15Z")

</div>

Correct, then you can check which one was successful. For this, you can use the task expression to get metadata on a task ([Expression reference - Dynatrace Docs](https://docs.dynatrace.com/docs/platform-modules/automations/workflows/reference#task)).  
Example:

```python
{% if task("task_1").state == "SUCCESS" %}
	Task 1 did run, result: {{ result("task_1") }}
{% else %}
	Task 2, result: {{ result("task_2") }}
{% endif %}

```

Updating Media

---

<div class="post-metadata">

**Author:** ![henk\_stobbe](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/henk_stobbe/32/30434_2.png) [@henk\_stobbe](https://community.dynatrace.com/u/henk_stobbe)\
**Post date:** [July 2, 2024, 1:17pm UTC](https://community.dynatrace.com/t/how-can-i-use-ex-result-xxxxx-with-multiple-pre-tasks/46414/5 "2024-07-02T13:17:50Z")

</div>

Again, perfect!
