# Resolve undefined variables error when evaluating loop expression in workflows

**URL:** <https://community.dynatrace.com/t/resolve-undefined-variables-error-when-evaluating-loop-expression-in-workflows/52710>\
**Category:** Automations\
**Tags:** workflows, automations\
**Created:** [July 30, 2025, 4:10am UTC](https://community.dynatrace.com/t/resolve-undefined-variables-error-when-evaluating-loop-expression-in-workflows/52710 "2025-07-30T04:10:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![p\_devulapalli](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/p_devulapalli/32/41590_2.png) [@p\_devulapalli](https://community.dynatrace.com/u/p_devulapalli)\
**Post date:** [July 30, 2025, 4:10am UTC](https://community.dynatrace.com/t/resolve-undefined-variables-error-when-evaluating-loop-expression-in-workflows/52710/1 "2025-07-30T04:10:43Z")

</div>

I am trying to create a workflow using a loop task which has a input from a DQL query. The loop task is referenced inside a HTTP request task . I keep getting the below error, looking for advice on what is that I am missing here please

Loop task

 ![p_devulapalli_3-1753848548916.png](https://global.discourse-cdn.com/dynatrace/original/3X/d/e/de4b85a15d137e5e6015c1eae6d0bc70229edba0.png)

 ![p_devulapalli_1-1753848424945.png](https://global.discourse-cdn.com/dynatrace/original/3X/f/6/f618a546b6b794028f3682fe81aa65cd30859c1a.png)

Error

 ![p_devulapalli_0-1753848342662.png](https://global.discourse-cdn.com/dynatrace/original/3X/6/e/6e5926457874e60a35c810a01c8324c913430842.png)

Unhandled failed task(s) during workflow execution:

monitoringmode\_update:  
Error evaluating loop expression. Undefined variables: records.

 ![p_devulapalli_2-1753848525974.png](https://global.discourse-cdn.com/dynatrace/original/3X/d/5/d5edcca94e338d82d34bd6194b926406edcdb23e.png)

---

<div class="post-metadata">

**Author:** ![izabelarokita](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/izabelarokita/32/41812_2.png) [@izabelarokita](https://community.dynatrace.com/u/izabelarokita)\
**Post date:** [December 15, 2025, 10:50am UTC](https://community.dynatrace.com/t/resolve-undefined-variables-error-when-evaluating-loop-expression-in-workflows/52710/2 "2025-12-15T10:50:13Z")

</div>

Hey&nbsp;[@p\_devulapalli](https://community.dynatrace.com/user/21657)&nbsp;,

I just wanted to check in and see if you still need help with this. If so, I’d be happy to look into it for you! 😊  
Please let me know what works best for you.

---

<div class="post-metadata">

**Author:** ![gdalessandro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/gdalessandro/32/5318_2.png) [@gdalessandro](https://community.dynatrace.com/u/gdalessandro)\
**Post date:** [May 18, 2026, 5:56pm UTC](https://community.dynatrace.com/t/resolve-undefined-variables-error-when-evaluating-loop-expression-in-workflows/52710/3 "2026-05-18T17:56:51Z")

</div>

I am still having the same issue with my workflow.&nbsp; I have a json response from a 3rd party api that has a listagent states. I am looping through the agentStates section of the json response and attempting to use a “Ingest Business Event” step to ingest each item in the list as its own event.

This is the input for the list:&nbsp;{{result(“get\_nice\_agents”)[“agentStates”]}}  
- Dynatrace validates this is a list

The variable name I am setting for each iteration is agentState.&nbsp; In my “Ingest Business Event” step I am using

{{ \_.agentState }} | to\_json

To reference the variable value of each iteration.

I get the following error:

Unhandled failed task(s) during workflow execution:

ingest\_business\_event\_2:  
Error evaluating loop expression. Undefined variables: agentStates.

The only place I am referencing “agentStates” is in the loop list definition.
