cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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!

 

 

4 REPLIES 4
RezaDorrani
Dual Super User II
Dual Super User II

Hi @Anonymous 

 

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

 

 

 

Anonymous
Not applicable

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.

Hi @Anonymous 

 

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

vnguyen1
Helper I
Helper I

@RezaDorrani 

https://powerusers.microsoft.com/t5/Using-Flows/how-to-output-string-value-out-of-json-parse/td-p/83...

i have looked into your solution for this flow issue. somehow i could not apply to my flow. do you have any suggestion ? please advice. Thanks

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Users online (2,183)