Skip to main content
Community site session details

Community site session details

Session Id : vhzt/EuhXkoIppQ7wgGzym
Power Automate - Building Flows
Unanswered

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.

Like (0) ShareShare
ReportReport
Posted on 14 Jul 2022 21:26:40 by 3,502

We have the following:-

 

1) SharePoint list which have a field of type People/Group which allow multiple selection

2) Planner

 

now we want to loop through all the SharePoint items >> and for each item >> to create a planner task >> assign the planner task to the users defined inside the People/Group field... but i am not sure how i can implement the scenario of building a comma separated list of a SharePoint People/Group field which allow multiple selection, so i can define this comma separated list inside the Assigned User Ids's planner field:-

 

johnjohn123_0-1657833957585.png

 

 

I also try this workflow:-

 

1) get all the SP items + initialize an array var

 

c1.PNG

 

2) initialize string var + loop through the SP items + build an array of the assigned users' emails 

 

c2.png

 

3) build a comma separated var string based on the array, add the string var to the create planner task:-

 

 

c3.png

 

 

but when i run the flow i got this 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.":-

 

johnjohn123_0-1657831627579.png

 

any advice?

  • Suggested answer
    CU22101443-0 Profile Picture
    2 on 22 Oct 2024 at 14:51:49
    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.
    Hi all, I think it is solved here:
     
     
    I don't know why the second loop is instantly created by power automate. If you access the needed values from your Get items group, it will be the iterated value.
     
  • Pstork1 Profile Picture
    67,104 Most Valuable Professional on 17 Jan 2024 at 14:05:19
    Re: 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.

    Please post this as a new question.  You'll get more responses and others will be able to find the answer more easily later.

  • mallelajyothi Profile Picture
    7 on 17 Jan 2024 at 13:47:50
    Re: 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.

    mallelajyothi_0-1705499037699.png

    I am also facing same issue, can you please help me.

  • Pstork1 Profile Picture
    67,104 Most Valuable Professional on 23 Aug 2023 at 13:59:37
    Re: 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 loop is running on Current Item, which is an object, not an array.  Not sure what order you added things in, but that Loop should not be there and isn't necessary.

  • PabloBaculinao Profile Picture
    6 on 22 Aug 2023 at 10:03:42
    Re: 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.

    Power Automate automatically add apply to each 2 when I add the email address of the LM on CC field of Send an email (V2). Please screenshot below.

    PabloBaculinao_0-1692698598592.png

     

  • Pstork1 Profile Picture
    67,104 Most Valuable Professional on 17 Aug 2023 at 12:51:15
    Re: 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.

    See previous answer.  The value you are using in the Apply to each 2 loop isn't an array its an object. You don't need the second loop.

  • PabloBaculinao Profile Picture
    6 on 17 Aug 2023 at 10:21:01
    Re: 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 am also getting the same error.

     

    PabloBaculinao_0-1692267624985.png

     

  • Pstork1 Profile Picture
    67,104 Most Valuable Professional on 07 Nov 2022 at 14:30:20
    Re: 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 due data is an indifidual field, not an array.  There shouldn't be a nested loop, just a single loop.

  • Efe_Ildem Profile Picture
    9 on 07 Nov 2022 at 07:58:26
    Re: 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.

    flow.pngflow2.png

    I have this easy problem but somehow i can't fix this. I need help. Thank you

  • shawn_fielding Profile Picture
    on 03 Nov 2022 at 20:34:57
    Re: 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 am getting this same error.  I actually took all actions out of the nested for loop.  So: 

    Apply to each: Value -> Apply to Each: Current Item

    Then nothing in it.  

    Errors out.  

    Did you ever get this working?

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2

Loading complete