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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Creating an Array per ...
Power Automate
Answered

Creating an Array per User from MS Graph

(0) ShareShare
ReportReport
Posted on by 8

Hey Everyone,

 

I'm pretty far down the road with a Flow to query the graph api for user delta changes. I just need to pass the JSON body to a Desktop Flow.

 

The output after a Parse JSON looks like this:

 

 

 

 

 

{
 "from": [
 {
 "jobTitle": "Retail Manager",
 "companyName": "Testing",
 "department": "Testing",
 "userPrincipalName": "AdeleV@y37.onmicrosoft.com",
 "country": "United States",
 "id": "152a2f01-2de6-4030-8b23-da0fafe2"
 },
 {
 "jobTitle": "Marketing Assistant",
 "companyName": "Testing",
 "department": "Testing",
 "userPrincipalName": "AlexW@y37.onmicrosoft.com",
 "country": "United States",
 "id": "ec31b4cd-b3b7-4e4b-89a8-c94921d"
 },
 {
 "department": "Testing",
 "userPrincipalName": "testadmin@y37.onmicrosoft.com",
 "id": "e3fe7172-7c9a-4463-9176-b0006c17b"
 },
 {
 "jobTitle": "HR Manager",
 "department": "Testing",
 "userPrincipalName": "DiegoS@y37.onmicrosoft.com",
 "country": "United States",
 "id": "db9b2dd7-7295-409a-a3d9-ade02982"
 },
 {
 "jobTitle": "Designer",
 "department": "Testing",
 "userPrincipalName": "GradyA@y37.onmicrosoft.com",
 "country": "United States",
 "id": "20836cc9-3bdf-445a-9d63-ce304b7c"
 }
 ]
}

 

 

 

 

 

 

And the Desktop Flow looks like this:

Screenshot 2022-06-17 174408.png

(the AddToGroup flow is just a test for a PowerShell script)

The mapping of the Desktop flow variables is easy. What I can't figure out is the For Each "user" component. What do I use to group the values by user? The best I've been able to get so far is an ungrouped array of values.

 

Cheers.

 

 

 

Categories:
I have the same question (0)
  • v-yujincui-msft Profile Picture
    on at

    Hi @MallonoX ,

     

    Do you want to get an object once by once?

     

    I have made a test for your reference.

    vyujincuimsft_0-1655789299905.png

    vyujincuimsft_1-1655789544465.png

    Result Screenshot:

    vyujincuimsft_2-1655789648414.png

    If you want to get the value of a field, you can select the corresponding dynamic content.

    vyujincuimsft_3-1655789808058.png

    Result Screenshot:

    vyujincuimsft_4-1655789874835.png

    In addition, I recommend that you hide your private information, such as using fictitious field values.

     

     

    Best Regards,
    Charlie Choi

  • MallonoX Profile Picture
    8 on at

    Hey @v-yujincui-msft 

     

    That's awesome! The first example is exactly what I'm after; where each loop contains a "set" of attributes.

     

    What are the expressions you used for 'from' and 'item'? I don't have either in the Dynamic Content list. Although I'm guessing 'from' is the Body of the preceding Parse JSON?

    I think whatever the expression is for 'item' is what I've been searching for.

     

    Cheers.

     

    Screenshot 2022-06-21 163504.png

     

     

  • Verified answer
    v-yujincui-msft Profile Picture
    on at

    Hi @MallonoX ,

     

    Maybe you could try to write the expressions manually.

     

    body('Parse_JSON_-_Users')?['from']
     
    items('Apply_to_each')
     
    vyujincuimsft_1-1655797300408.png

    Result Screenshot:

    vyujincuimsft_2-1655797375344.png

     

     

     

    Best Regards,
    Charlie Choi

  • MallonoX Profile Picture
    8 on at

    Hey @v-yujincui-msft 

     

    You're a legend! That didn't work specifically because I realized the example Parse JSON I posted in my initial post was from a different Graph query and the "from" field wasn't there, which is why I didn't see it in the Dynamic Content expressions. But applying the same logic worked a treat. 😁

     

    This is the expression that worked for me: 

    body('Parse_JSON_-_Users')?['value']

     

    What I've now realized was causing the problem is the "automatic" Dynamic Content expression for "value" is:

    body('Parse_JSON_-_Users')?[body]?['value']

     

    Screenshot 2022-06-22 105314.png

     

    For future reference I had to make custom expressions for each of the variables in the desktop flow, e.g.:

    outputs('Compose')['department']
    outputs('Compose')['id']
    outputs('Compose')['jobTitle']
     
    Cheers.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard