web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Apply to each not work...
Power Automate
Unanswered

Apply to each not working after get items

(0) ShareShare
ReportReport
Posted on by 50

I have a flow where I get all items in a filtered sharepoint list and create an excel spreadsheet.  I get an error at the apply to each

 

StuC_0-1669146379682.png

 

I put the Value - list of items in the "Select an output from previous steps" field.  Is this where I go wrong?

StuC_2-1669146563171.png

 

StuC_1-1669146504143.png

 

result is "The execution of template action 'Apply_to_each_3' failed: the result of the evaluation of 'foreach' expression '@items('Apply_to_each_4')?['ID']' is of type 'Integer'. The result must be a valid array."

 

Categories:
I have the same question (0)
  • David_MA Profile Picture
    12,957 Super User 2025 Season 2 on at

    I don't understand why you have so many apply to each actions with none of them doing anything. That would be one problem. However, the problem causing the error is that you put an ID field in your Apply to each 3 action. As the error message says, you need to use an array and an ID would return a single value. This article will explain what an array is: Power Automate Arrays: The Common Operations Guide 2022 (zeitgeistcode.com).

     

    Here is an example of a workflow where I have nested apply to each actions. This is a temp workflow, so I didn't update the names of the actions and since it is working, I don't want to rename things now since it will be deleted once I get the go-ahead to run it on all items.

     

    However, what it is doing is looking at items in a list based on certain criteria (basically, requests that are still open). We added a new field to the list, and the data that populates this field comes from another list on another site. To avoid having to manually open every item and update the form so it populates the new field, I have written a flow to do this.

     

    Main part of flow:

    David_MA_0-1669150592564.png

    Apply to each expanded:

    David_MA_1-1669150668793.png

    • The value in the first Select an output... in the Apply to each is the Value from the Get items action after the trigger action. This is followed by the Get items 2 action, which pulls data that I need to update the original Get items action with. It uses a filter query based in the original Get items action that is passed to the first Apply to each:
      David_MA_2-1669150870879.png

       

    • I know this will only return one value, as the job code is unique in the Get items 2 action.
    • The Apply to each 2 has the value from the Get items 2 action. Even though I know there is only one result, Power Automate will put this into an Apply to each.
    • The Compose Max Value gets populated with the corresponding value from the second Get items action. I know I will only get one value returned, but if whatever you were doing did not return just one item, the last value the apply to each found would be populated in this compose action.
    • I then use the value in the compose action to go back and update the item from the original Get items action.

    Hopefully this makes sense and illustrates how to use nested apply to each actions. Although, it barely makes sense to me, but I am not sure how to explain it better 🙂

  • grantjenkins Profile Picture
    11,063 Moderator on at

    A few questions for you so we might be able to re-architect your flow to give you what you want.

     

    1. Are you able to show the rest of your flow to see exactly what you have in the last Apply to each?
    2. Are you trying to create an Excel File or just a CSV file?
      1. If just a CSV file containing columns from your filtered Get items then you may not even need an Apply to each.
      2. If an Excel file, how are you creating it as you can't just create an Excel file unless you're creating it from an existing Excel file. And if an Excel file you should only need a single Apply to each.

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard