Notifications
Announcements
Hello Power Platform Community,
I am encountering an issue in Copilot Studio where I cannot access variables (both global and non-global) from within a For Each loop. Here is the situation:
For Each
DealersPayload
Here’s an example of my setup:
Variable Initialization (outside the loop): - kind: SetVariable id: setVariable_DealersPayload variable: DealersPayload value: "[]"
Inside the Loop: - kind: Foreach id: foreach_Top items: =Topic.Top5 value: CurrentTopDealer actions: - kind: SetVariable id: setVariable_UpdatePayload variable: DealersPayload value: | JSON( Concat( DealersPayload, "[", If( Length(DealersPayload) > 2, ",", "" ), "{", "\"Dealer_Code\": \"", Text(CurrentTopDealer.Value), "\",", "\"Score\": ", Text(CurrentTopDealer.Score), ",", "\"Category\": \"Top\"", "}", "]" ) )
However, every time I try to use DealersPayload inside the loop, I get an error saying the variable is not recognized. This happens even when I declare DealersPayload as a global variable.
I would greatly appreciate any insights, workarounds, or guidance on how to resolve this issue.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
In our never-ending quest to improve we are simplifying the forum hierarchy…
We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Michael E. Gernaey 251 Super User 2025 Season 2
Romain The Low-Code... 201 Super User 2025 Season 2
S-Venkadesh 93 Moderator