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
Solution Sage
Solution Sage

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
Solution Sage
Solution Sage

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
Solution Sage
Solution Sage

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


Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,924)