<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Error evaluating custom condition. Undefined variables: list object has no element 0. in Automations</title>
    <link>https://community.dynatrace.com/t5/Automations/Error-evaluating-custom-condition-Undefined-variables-list/m-p/301427#M2656</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I've created a workflow for Dynatrace-Service Now integration.&lt;/P&gt;&lt;P&gt;On this step, it returns this error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="erh_inetum_0-1782899242499.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/33577i97B19BD6C0BFD388/image-size/medium?v=v2&amp;amp;px=400" role="button" title="erh_inetum_0-1782899242499.png" alt="erh_inetum_0-1782899242499.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But the previous step has State "Success"&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="erh_inetum_1-1782900054690.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/33578i3BC14954CB65A879/image-size/medium?v=v2&amp;amp;px=400" role="button" title="erh_inetum_1-1782900054690.png" alt="erh_inetum_1-1782900054690.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The condition of the step that is failing is this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="erh_inetum_2-1782900141116.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/33579i7CFAFE0CF5B83DA8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="erh_inetum_2-1782900141116.png" alt="erh_inetum_2-1782900141116.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Does anyone know why it's failing in spite of the previous step is returning Success and how to fix this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Elena.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 Jul 2026 10:13:12 GMT</pubDate>
    <dc:creator>erh_inetum</dc:creator>
    <dc:date>2026-07-01T10:13:12Z</dc:date>
    <item>
      <title>Error evaluating custom condition. Undefined variables: list object has no element 0.</title>
      <link>https://community.dynatrace.com/t5/Automations/Error-evaluating-custom-condition-Undefined-variables-list/m-p/301427#M2656</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I've created a workflow for Dynatrace-Service Now integration.&lt;/P&gt;&lt;P&gt;On this step, it returns this error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="erh_inetum_0-1782899242499.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/33577i97B19BD6C0BFD388/image-size/medium?v=v2&amp;amp;px=400" role="button" title="erh_inetum_0-1782899242499.png" alt="erh_inetum_0-1782899242499.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But the previous step has State "Success"&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="erh_inetum_1-1782900054690.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/33578i3BC14954CB65A879/image-size/medium?v=v2&amp;amp;px=400" role="button" title="erh_inetum_1-1782900054690.png" alt="erh_inetum_1-1782900054690.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The condition of the step that is failing is this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="erh_inetum_2-1782900141116.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/33579i7CFAFE0CF5B83DA8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="erh_inetum_2-1782900141116.png" alt="erh_inetum_2-1782900141116.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Does anyone know why it's failing in spite of the previous step is returning Success and how to fix this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Elena.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2026 10:13:12 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/Error-evaluating-custom-condition-Undefined-variables-list/m-p/301427#M2656</guid>
      <dc:creator>erh_inetum</dc:creator>
      <dc:date>2026-07-01T10:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: Error evaluating custom condition. Undefined variables: list object has no element 0.</title>
      <link>https://community.dynatrace.com/t5/Automations/Error-evaluating-custom-condition-Undefined-variables-list/m-p/301428#M2657</link>
      <description>&lt;P&gt;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).&lt;/P&gt;&lt;P&gt;However, your comment_on_incident step's custom condition is trying to access:&lt;BR /&gt;{{ result("search_incident")[0].sys_id }}&lt;/P&gt;&lt;P&gt;This fails because there's no element at index [0] in an empty/null result, causing the error: "list object has no element 0"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You need to check if the search actually returned results before accessing the first element.&lt;BR /&gt;try to modify the custom condition to:&lt;/P&gt;&lt;P&gt;{{ result("search_incident") and len(result("search_incident")) &amp;gt; 0 and result("search_incident")[0].sys_id }}&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2026 10:21:53 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/Error-evaluating-custom-condition-Undefined-variables-list/m-p/301428#M2657</guid>
      <dc:creator>PacoPorro</dc:creator>
      <dc:date>2026-07-01T10:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Error evaluating custom condition. Undefined variables: list object has no element 0.</title>
      <link>https://community.dynatrace.com/t5/Automations/Error-evaluating-custom-condition-Undefined-variables-list/m-p/301435#M2658</link>
      <description>&lt;P&gt;Hi Paco,&lt;/P&gt;&lt;P&gt;Thanks you so much for your quick answer.&lt;/P&gt;&lt;P&gt;You're right. The&amp;nbsp;&lt;SPAN&gt;State info is null. That's because it doesn´t find any incidents.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="erh_inetum_0-1782903209065.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/33580i919BB4E3995219A1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="erh_inetum_0-1782903209065.png" alt="erh_inetum_0-1782903209065.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I've put the condition you told me and it returns this:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Error evaluating custom condition. Undefined variables: len.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you Paco!&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Elena.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2026 11:58:43 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/Error-evaluating-custom-condition-Undefined-variables-list/m-p/301435#M2658</guid>
      <dc:creator>erh_inetum</dc:creator>
      <dc:date>2026-07-01T11:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: Error evaluating custom condition. Undefined variables: list object has no element 0.</title>
      <link>https://community.dynatrace.com/t5/Automations/Error-evaluating-custom-condition-Undefined-variables-list/m-p/301446#M2659</link>
      <description>&lt;P&gt;Hi again Paco,&lt;/P&gt;&lt;P&gt;As I told you, this:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;{{ result("search_incident") and len(result("search_incident")) &amp;gt; 0 and result("search_incident")[0].sys_id }}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;returns Error.&lt;/P&gt;&lt;P&gt;But this:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;{% if result("search_incident") and result("search_incident")|length &amp;gt; 0 %}&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{{ result("search_incident")[0].sys_id }}&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{% endif %}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;returns results onces there is created incidents:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="erh_inetum_0-1782908703542.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/33585i6AD698768A0556E1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="erh_inetum_0-1782908703542.png" alt="erh_inetum_0-1782908703542.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I've run again the workflow and now the workflow ends successfully but it skips the two next steps:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="erh_inetum_1-1782909056447.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/33588i7A3D4D2E27137045/image-size/medium?v=v2&amp;amp;px=400" role="button" title="erh_inetum_1-1782909056447.png" alt="erh_inetum_1-1782909056447.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Thanks a lot for the clues.&lt;BR /&gt;Best Regards,&lt;BR /&gt;Elena.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2026 12:38:00 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/Error-evaluating-custom-condition-Undefined-variables-list/m-p/301446#M2659</guid>
      <dc:creator>erh_inetum</dc:creator>
      <dc:date>2026-07-01T12:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Error evaluating custom condition. Undefined variables: list object has no element 0.</title>
      <link>https://community.dynatrace.com/t5/Automations/Error-evaluating-custom-condition-Undefined-variables-list/m-p/301450#M2660</link>
      <description>&lt;P&gt;{% if result("search_incident") and result("search_incident")|length &amp;gt; 0 %}&lt;BR /&gt;{{ result("search_incident")[0].sys_id }}&lt;BR /&gt;{% endif %}&lt;BR /&gt;&lt;BR /&gt;You're right, my solution included python intead of jinja &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So now, the behavior is working as intended:&lt;/P&gt;&lt;P&gt;&amp;nbsp;No incident found → Custom condition evaluates to false/empty&lt;BR /&gt;&amp;nbsp;"Run this task if" condition fails → Step is skipped&lt;BR /&gt;&amp;nbsp;Subsequent steps that depend on this one → Also skipped (cascading skip)&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2026 14:07:59 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/Error-evaluating-custom-condition-Undefined-variables-list/m-p/301450#M2660</guid>
      <dc:creator>PacoPorro</dc:creator>
      <dc:date>2026-07-01T14:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: Error evaluating custom condition. Undefined variables: list object has no element 0.</title>
      <link>https://community.dynatrace.com/t5/Automations/Error-evaluating-custom-condition-Undefined-variables-list/m-p/301479#M2661</link>
      <description>&lt;P&gt;Hi Paco,&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Have a nice day.&lt;BR /&gt;Regards,&lt;BR /&gt;Elena.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2026 05:08:34 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Automations/Error-evaluating-custom-condition-Undefined-variables-list/m-p/301479#M2661</guid>
      <dc:creator>erh_inetum</dc:creator>
      <dc:date>2026-07-02T05:08:34Z</dc:date>
    </item>
  </channel>
</rss>

