Hi,
I’ve created a workflow for Dynatrace-Service Now integration.
On this step, it returns this error:
But the previous step has State “Success”
The condition of the step that is failing is this:
Does anyone know why it’s failing in spite of the previous step is returning Success and how to fix this?
Thanks in advance.
Regards,
Elena.
Probably the search_incident step has State: Success but State info: null - meaning the search executed successfully but found no incidents (returned an empty result).
However, your comment_on_incident step’s custom condition is trying to access:
{{ result(“search_incident”)[0].sys_id }}
This fails because there’s no element at index [0] in an empty/null result, causing the error: “list object has no element 0”
You need to check if the search actually returned results before accessing the first element.
try to modify the custom condition to:
{{ result(“search_incident”) and len(result(“search_incident”)) > 0 and result(“search_incident”)[0].sys_id }}
Hi Paco,
Thanks you so much for your quick answer.
You’re right. The State info is null. That’s because it doesn´t find any incidents.
I’ve put the condition you told me and it returns this:
Error evaluating custom condition. Undefined variables: len.
Thank you Paco!
Regards,
Elena.
Hi again Paco,
As I told you, this:
{{ result(“search_incident”) and len(result(“search_incident”)) > 0 and result(“search_incident”)[0].sys_id }}
returns Error.
But this:
{% if result(“search_incident”) and result(“search_incident”)|length > 0 %}
{{ result(“search_incident”)[0].sys_id }}
{% endif %}
returns results onces there is created incidents:
I’ve run again the workflow and now the workflow ends successfully but it skips the two next steps:
I think it’s working properly now and this behaviour it’s normal. And if it’s skipping the next following steps and doesn’t do anything else, I think it’s because the created incident hasn´t been any changes so far. And as no further issues have been creating in Problems, there’s nothing new for it to create either.
Thanks a lot for the clues.
Best Regards,
Elena.
{% if result(“search_incident”) and result(“search_incident”)|length > 0 %}
{{ result(“search_incident”)[0].sys_id }}
{% endif %}
You’re right, my solution included python intead of jinja 
So now, the behavior is working as intended:
No incident found → Custom condition evaluates to false/empty
“Run this task if” condition fails → Step is skipped
Subsequent steps that depend on this one → Also skipped (cascading skip)
Hi Paco,
Thank you very much for confirming how the workflow behaves once the condition has been changed and it’s correct and for the very detailed explanation of the steps.
Have a nice day.
Regards,
Elena.