cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

henk_stobbe
DynaMight Champion
DynaMight Champion

Hello workflow fans!  😀

I have a task that can be triggered by  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

4 REPLIES 4

ChristopherHejl
Dynatrace Helper
Dynatrace Helper

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

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

ChristopherHejl_2-1719922530977.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

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 (https://docs.dynatrace.com/docs/platform-modules/automations/workflows/reference#if-statement) or default filter (https://docs.dynatrace.com/docs/platform-modules/automations/workflows/reference#filters)

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  3 will finish. 3 needs the result of 1 or 2 to proceed.

KR Henk

ChristopherHejl
Dynatrace Helper
Dynatrace Helper

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).
Example: 

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

 
Updating Media

 

Again, perfect!

Featured Posts