web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to iterate over GU...
Power Automate
Unanswered

How to iterate over GUIDs and access id and name in Apply to each

(1) ShareShare
ReportReport
Posted on by 12
Hi Community,
 
I know this error is usually about needing an array in Apply to each, but in my case, my data is a dynamic object, not an array.

Here’s an example of my data:

{
  "animals": {
    "429defc8-5b05-4c3e-920d-0bb911a61345": {
      "id": "429defc8-5b05-4c3e-920d-0bb911a61345",
      "name": "camel"
    },
    "429defc8-5b05-4c3e-920d-0bb911a613451": {
      "id": "429defc8-5b05-4c3e-920d-0bb911a613451",
      "name": "elephant"
    }
  }
}


How can I iterate over the GUID keys (like 429defc8-5b05-4c3e-920d-0bb911a61345) and access both id and name for each animal in an Apply to each or Select action?

I want to know the correct expression to use for this scenario where my object keys are dynamic GUIDs, NOT a simple array.

I already know about the array error, but my case is different due to the dynamic object structure.

What expression should I use to get this working?

Thanks!
111.png
333.png
222.png
Categories:
I have the same question (0)
  • Chriddle Profile Picture
    8,672 Super User 2026 Season 1 on at
    You can use xpath to do this:
     
     
    Select From:
    xpath(
        xml(outputs('Compose')),
        '//animals/*'
    )
     
    Select Map:
    json(
    	item()
    )[
    	first(
    		xpath(
    			xml(item()),
    			'/*/id/text()'
    		)
    	)
    ]
     
  • Chriddle Profile Picture
    8,672 Super User 2026 Season 1 on at
     
    Select From:
    xpath(
        xml(outputs('Compose')),
        '//animals/*/id/text()'
    )
     
    Select Map:
    outputs('Compose').animals[item()]
     
     
  • Parthiban759 Profile Picture
    56 on at

    if you also need the GUID keys (not just values):

    If you need both the keys and values, use:

    json(string(outputs('AnimalsRaw')?['animals']))
     

    And loop over:

    union(
    createArray(),
    outputs('ComposeWithAnimalsObject')
    )

    Then inside the loop, use:

    • item()?['Key']

    • item()?['Value']?['id']

    • item()?['Value']?['name']

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.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard