cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CricketCO
Helper I
Helper I

Get files (properties only)>Send an email (V2) adds "Apply to each" & breaks flow

I had a scheduled cloud flow that was working fine and suddenly stopped. I went in to the errors and was told the issue was in the email step, so I tried editing there.

 

Power Automate then added a bunch of "apply to each" controls that I cannot get rid of (see bottom of screenshot). I tried dragging my "send an email" action out of the "apply to each 2" control and it tells me I cannot do that. I also tried deleting that whole step and re-adding it. Power Automate just added the two "apply to each" controls in again.

 

The controls make logical sense, but it is still broken. 

CricketCO_0-1644269252180.png

This is the most recent error when I try manually running it: The execution of template action 'Apply_to_each_2' failed: the result of the evaluation of 'foreach' expression '@items('Apply_to_each')' is of type 'Object'. The result must be a valid array.

 

The second "apply to each" always shows up when I use dynamic content to grab the email address of the file owner for each file:

CricketCO_0-1644275666440.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-yujincui-msft
Community Support
Community Support

Hi @CricketCO ,

 

Is the "Content Owner" a Person column that you added manually?

Maybe you could add a Compose Action to get the value of this field.

I have made a test for your reference.

 

1. Here is my selected folder.

vyujincuimsft_0-1644545259830.png

2. Create a flow.

item()?['ContentOwner']
item()?['Email']
item()?['DisplayName']
vyujincuimsft_0-1644546077319.png

Result Screenshot: 

vyujincuimsft_1-1644546139353.png

 

 

Best Regards,

Charlie Choi

View solution in original post

6 REPLIES 6
CricketCO
Helper I
Helper I

I tried setting this up another way with the "get files (properties only)" just grabbing the whole library and the "send an email" happening downstream if the condition was met. Power Automate, again, threw the whole thing into "Apply to each" containers and it, again, is having an issue due to the "Apply to each"s being objects not arrays.

CricketCO_0-1644332550425.png

 

v-yujincui-msft
Community Support
Community Support

Hi @CricketCO ,

 

Do you want to send an email to the creator of each file in the document library?

I have made a test and it works fine on my side.

 

1. Here is my selected folder.

vyujincuimsft_0-1644479572087.png

2. Create a flow.

vyujincuimsft_1-1644479741809.png

Applytoeach.gif

Result Screenshot:

vyujincuimsft_2-1644479777587.png

 

 

Best Regards,

Charlie Choi

Hi Charlie, 

No, I am trying to send an email to the person (or people) designated as the Content Owner of the file. This may be multiple people which seems to be the issue.

As soon as I select the dynamic content type of "Content Owner" in the "to" field, it automatically creates that loop of a second "apply to each."

Based on the error - The execution of template action 'Apply_to_each_2' failed: the result of the evaluation of 'foreach' expression '@items('Apply_to_each')' is of type 'Object'. The result must be a valid array - the issue seems to be that one or both of these Apply to each outputs is an object.

Can you advise on how I can split the potentially multiple email addresses that may be in one file's "Content Owner" field to make this work? Let me know if you need more information.

Thank you!

v-yujincui-msft
Community Support
Community Support

Hi @CricketCO ,

 

Is the "Content Owner" a Person column that you added manually?

Maybe you could add a Compose Action to get the value of this field.

I have made a test for your reference.

 

1. Here is my selected folder.

vyujincuimsft_0-1644545259830.png

2. Create a flow.

item()?['ContentOwner']
item()?['Email']
item()?['DisplayName']
vyujincuimsft_0-1644546077319.png

Result Screenshot: 

vyujincuimsft_1-1644546139353.png

 

 

Best Regards,

Charlie Choi

Thank you! Yes, Content Owner is a column I manually added to the SharePoint list. I'm working on building out what you tested. It is adding a third "apply to each" thus far. I'll let you know if it works. Here's what I've got built:

CricketCO_1-1644589059896.png

  • Content_x0020_Owner is the internal column name.

CricketCO_3-1644589198678.png

  • Power Automate automatically added in that third "apply to each" as soon as I selected "Content Owner Email" from the Dynamic content. This is exactly what it did before, but previously it was a 2nd "apply to each" rather than a third.

I made a couple tiny edits (I didn't realize you literally meant to put Item()?['ContentOwner']). This is where I landed, and it is working!

CricketCO_4-1644592381676.png

Thank you very much for your help. I appreciate it!

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (6,099)