cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
JoeO
Level: Powered On

Return value from multiple array entries

Hi,

 

I have an array called "in_groups". The "in_group" array has a value called "group_label". I would like to create an expression that would return just the value of both group lables. Normally, this would be a for-each operation, but i would like to combine the results so that my output looks like this:

 

All users

Global Users 

 

{
"in_groups": [
{
"group_id": 2,
"group_label": "All users",
"_is_system": true
},
{
"group_id": 4,
"group_label": "Global Users",
"_is_system": false
}
]
}

4 REPLIES 4
Community Support Team
Community Support Team

Re: Return value from multiple array entries

Hi @JoeO,

 

Could you please share a screenshot of your flow's configuration?

 

I have made a test on my side and please take a try with the following workaround:

  • Add a proper trigger, here I use Flow Button trigger.
  • Add a Compose action, Inputs field set to following json data that you provided:
{
"in_groups": [
{
"group_id": 2,
"group_label": "All users",
"_is_system": true
},
{
"group_id": 4,
"group_label": "Global Users",
"_is_system": false
}
]
}
  • Add a Variables-> "Initialize variable" action, Name set to FinalValue, Type set to String and Value set to empty.
  • Add a "Apply to each" action, input parameter set to following formula:
outputs('Compose')?['in_groups']
  • Within "Apply to each" action, add a "Compose 2" action, Inputs set to FinalValue variable. Add a "Compose 3" action, Inputs set to following formula:
item()?['group_label']

Add a "Set variable" action, Name set to FinalValue variable, Value set to following formula:1.JPG

In first line, type the output of the "Compose 3" action. In second line, type the output of the "Compose 2" action.

 

  • Under "Apply to each" action, add a "Compose 4" action, Inputs field set to FinalValue variable.

Image reference:2.JPG

 

3.JPG

 

 

The flow works successfully as below:4.JPG

 

More details about using expression in flow actions, please check the following article:

Use expression in flow actions 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
JoeO
Level: Powered On

Re: Return value from multiple array entries

Hi Kris,

Thanks so mcuh for the detailed response. Really appreciate your insight. I've tested it, and get the desired results in the second “Apply to each” step. The question is, i've been trying to understand what it is that you're doing, but im not fully understanding it. If you dont mind, can you give me a brief explanation on what we’re doing here, especially the initialize variable step and the 2 outputs?

 

JoeO
Level: Powered On

Re: Return value from multiple array entries

I actually tried the "Select" operation as a more simple approach, and it seems to work, but im trying to figure out (if possible) how to just retrieve the values w/o the rest. Currently im getting this (with the select operation):

[
"All users",
"Global User"
]

 

In_Group.png

 

JoeO
Level: Powered On

Re: Return value from multiple array entries

Reviewed this again real quick, i do understand the solution and its working well. Just wondering whether its possible to simplify, esle i'll stick with this.

 

Thanks!!

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 403 members 6,147 guests
Please welcome our newest community members: