cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
overheadpress18
Advocate I
Advocate I

How to select certain elements of JSON

I am having issues selecting all of the "name" elements as underlined on the right hand side of the picture below into my Power Automate on the left.

 

The expression I am attempting is giving me the following error: "InvalidTemplate. The execution of template action 'Select' failed: The evaluation of 'query' action 'where' expression '{ "Name": "@variables('array1')['value']['name']" }' failed: 'The template language expression 'variables('array1')['value']['name']' 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.'."

 

What am I missing? Let me know if more info is required. Thanks!

help1.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
mahoneypat
Super User
Super User

The pic doesn't show the start, so it sounds like there is an outer array too.  Does this work?

 

variables('array1')?[0]?['value']?[0]?['name']

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
mahoneypat
Super User
Super User

Looks like "value" is an array, so to get the name field of the first element use

 

variables('array1')?['value']?[0]?['name']

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thanks for the reply Pat, unfortunately I am still getting the same error message: 

 

 The execution of template action 'Select' failed: The evaluation of 'query' action 'where' expression '{ "Name": "@variables('array1')?['value']?[0]?['name']" }' failed: 'The template language expression 'variables('array1')?['value']?[0]?['name']' 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.'.

mahoneypat
Super User
Super User

The pic doesn't show the start, so it sounds like there is an outer array too.  Does this work?

 

variables('array1')?[0]?['value']?[0]?['name']

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Users online (2,576)