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

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
Helper II
Helper II

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
Helper II
Helper II

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
Helper II
Helper II

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 III
Helper III

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
Helper II
Helper II

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 III
Helper III

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 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 (3,905)