cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

How to access the value of an array

Hi, is there a way to get the value of these using expression like @{first(body('Get_all_referrals')?['value'])?['id']}? I just want to get the values without using "Apply to each" action to loop inside the array of an array.

 

Capture.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: How to access the value of an array

It should be something like this:

 

body('Get_all_referrals')?['value'][0]?['customerProfile']['team'][0]?['email']





Did my reply help? Please give it a thumbs up.
Did I answer your question? Please mark my post as a solution!
If you liked my response, please consider giving it a thumbs up. THANKS!


Proud to be a Flownaut!





Community Leader: Black Country PowerApps & Flow User Group

View solution in original post

8 REPLIES 8
Highlighted
Super User
Super User

Re: How to access the value of an array

You can use either the "first" expression, or what I prefer to do is identify the exact array index. E.g. if I wanted just the first item then I could do something like this:

 

items()?['items'][0]?['team'][0]?['properties'][0]?['email']





Did my reply help? Please give it a thumbs up.
Did I answer your question? Please mark my post as a solution!
If you liked my response, please consider giving it a thumbs up. THANKS!


Proud to be a Flownaut!





Community Leader: Black Country PowerApps & Flow User Group

Highlighted
Frequent Visitor

Re: How to access the value of an array

Thanks for your reply. How can i achieve it with this. Thanks in advance.
Capture.PNG

Highlighted
Super User
Super User

Re: How to access the value of an array

It should be something like this:

 

body('Get_all_referrals')?['value'][0]?['customerProfile']['team'][0]?['email']





Did my reply help? Please give it a thumbs up.
Did I answer your question? Please mark my post as a solution!
If you liked my response, please consider giving it a thumbs up. THANKS!


Proud to be a Flownaut!





Community Leader: Black Country PowerApps & Flow User Group

View solution in original post

Highlighted
Frequent Visitor

Re: How to access the value of an array

Thanks. I haven't tested the expression due access limitation for now, hopefully later given permission but i managed to do the expression using the format you've given.

 

Is that format can be also used in in this flow? They have the same JSON schema.

Capture.PNG

 

I got this error:


Capture1.PNG

 

InvalidTemplate. Unable to process template language expressions in action 'Set_variable_2' inputs at line '1' and column '2090': 'The template language expression 'body('Parse_JSON')?['value'][0]?['customerProfile']['team'][0]?['email']' cannot be evaluated because property 'value' cannot be selected. Array elements can only be selected using an integer index. Please see https://aka.ms/logicexpressions for usage details.'.

Highlighted
Frequent Visitor

Re: How to access the value of an array

Thanks. This one works. So, as long as the ['team'] in body('Get_all_referrals')?['value'][0]?['customerProfile']['team'][0]?['email'] is not empty. 

Highlighted
Super User
Super User

Re: How to access the value of an array

Hi @linojr_asmolo you could build a number of checks in before hand to make sure that the values are there.

 

E.g. you could use an expression: length(body('Get_all_referrals')?['value'][0]?['customerProfile']['team']) to see if it's greater than 0 (a team is present).





Did my reply help? Please give it a thumbs up.
Did I answer your question? Please mark my post as a solution!
If you liked my response, please consider giving it a thumbs up. THANKS!


Proud to be a Flownaut!





Community Leader: Black Country PowerApps & Flow User Group

Highlighted
Frequent Visitor

Re: How to access the value of an array

@MattWeston365 , Yupz, i've used that in the flow to check whether it's empty. Thanks, with the syntax you've shared, that gives me an understanding of how to access array. And I was able to modify the query expression in different ways. Thanks, this is really a big help.

Highlighted
Frequent Visitor

Re: How to access the value of an array

Hi @MattWeston365 , how do i append an object to an array of type variable?

This is the schema of my variable Owner:

 

Capture.PNG

 

This my Append Action:

Capture.PNG

 

But this gives me an error.
Do you know something about it?

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

Top Solution Authors
Users online (7,822)