cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Antonioclk
Helper IV
Helper IV

Apply_to_each error when running a flow for retrieving all office users into a sharepoint list

Hello,

i'm trying to make a flow for retrieving all my office users inside a sharepoint list.

i made a simple flow, also checking this post but after running for few minutes i get this error

Action 'Apply_to_each_2' failed

 

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.

 

 

I attach an image of the flow and of the error.

how can i fix? how can i succeed in my task? thank you so much

 

flowflow

errorerror

1 ACCEPTED SOLUTION

Accepted Solutions
Koen5
Resolver III
Resolver III

Dear Antonio,

Did the flow timed out while you are watching the flow steps?

This does not necessarily mean that the flow is not working properly ... this can be confusing sometimes.

When you see the flow 'Timed out' while watching the flow steps, leave this screen and go to the 'previous' flow page where you see all the details of the flow (connections, descriptions, etc.).

There you will get a better view wether the flow is still running or actually timed out.

 

Hope this helps.

Regards,

Koen

View solution in original post

6 REPLIES 6
Koen5
Resolver III
Resolver III

Dear Antonio,

 

The problem lies in the output you have selected from the 'Search for users' action and fed into the 'Apply_to_each'. 

A 'Apply_to_each' expects an array to operate, the output you have selected is apparently not in an array format.

Either you select a different output from the 'Search for users' action which does have an array format or you need to compile the output into an array before you can loop through it via the 'Apply_to_each'.

 

If this has offered you a solution to the issue, please state so in the thread.

Kind regards,

Koen

Hi Koen and thank you for your reply. I followed the link in my post where they did the same thing and it worked for them. Actually it is also weird that the error comes out after the flow is running for over 5 minutes. 

Can you help me find a way to fix it? i put the output in a compose and i get a HUGE array... so can't be that the issue 😞

Koen5
Resolver III
Resolver III

Dear Antonio,

Can you limit the output and first see if you can process for example the first 10 items correctly?

If you can, then the issue may be the huge amount of data retrieved and possibly you need to adjust the default limitations of the Power Automate actions used.

 

Kind regards,

Koen

Antonioclk
Helper IV
Helper IV

i just realized that the error was due to some info missing. I explain myself better. 
I used the flow to fill up a sharepoint list, but not every user had all data so it would fail. 

Now i limited the flow to 3 data that are mandatory and i get "flow run timed out" after 11 minutes.

 

how can i fix this? As you said it is probably due to the huge amount of data retrieved... probably thousands users. How could i get all users without the flow going in overflow?

Koen5
Resolver III
Resolver III

Dear Antonio,

Did the flow timed out while you are watching the flow steps?

This does not necessarily mean that the flow is not working properly ... this can be confusing sometimes.

When you see the flow 'Timed out' while watching the flow steps, leave this screen and go to the 'previous' flow page where you see all the details of the flow (connections, descriptions, etc.).

There you will get a better view wether the flow is still running or actually timed out.

 

Hope this helps.

Regards,

Koen

Antonioclk
Helper IV
Helper IV

wow you are right, actually it says it's still running, and in my sharepoint list i start to see items been populated!!! 

thank you so much

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

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.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (2,881)