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

Apply to each Expression Evaluation Failed when building string

Apply to each Expression Evaluation Failed when building email string

Initialize varialbes: GroupID (int), strEmailRecipient (str)

1.png

Note the GroupID is used in the () to quesry the correct sitegroups and $select Email of all members. And the HTTP requests returns green.2.png

 

3.png

 

How the 'Parse JSON' step is configured:4.png

 

Which runs successfully during test:5.png

 

Here is how the 'Apply to each' is configured to build a string of email addresses:6.png

 

And the error message during test:7.png

 

I've tried adding ?[0]?['Email'] and error becomes:

The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@{body('Parse_JSON')?['d']?['results']}?[0]?['Email']' is of type 'String'. The result must be a valid array.

Same results when I add item()? before the email in the value 'Append to string variable'.

If only there was a step to query SPO groups for emails... but La..

Thanks in advance!

 

 

3 REPLIES 3
Highlighted
Dual Super User
Dual Super User

Re: Apply to each Expression Evaluation Failed when building string

Hi @Dotty 

 

After the send an http request action which returns the users within the group

 

Run a for loop with following expression

body('Send_an_HTTP_request_to_SharePoint')?['value']

 

within loop

append to string variable

item()?['Email']

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

 

Highlighted
Regular Visitor

Re: Apply to each Expression Evaluation Failed when building string

You pointed me the right direction! And my sanity thanks you @RezaDorrani!

So I removed the parse json step.

Added the 'apply to each' directly after the 'send an http request to SharePoint' and  

manually added the following to the 'select an output..' through the expression builder:

 

body('Send_an_HTTP_request_to_SharePoint')?['value']

 

then added the following to the 'append to string variable' through the expression builder:

 

items('Apply_to_each')?['Email']

 

to the value and BAM! Bob's your uncle. Works like a champ.

Highlighted
Dual Super User
Dual Super User

Re: Apply to each Expression Evaluation Failed when building string

Hi @Dotty 

 

Glad it worked out for you

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

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

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

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
Top Kudoed Authors
Users online (7,750)