Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

The execution of template action 'Apply_to_each_3' failed: the result of the evaluation of 'foreach' expression '@items('Apply_to_each')' is of type 'Object'. The result must be a valid array.

(0) ShareShare
ReportReport
Posted on by 21

Hi,

 

I am trying to filter files in an array I have (using "Filter Array") and then delete the files in the folder I am filtering that are older than 15 days.  The old files are the output of the "Filter Array" action.  I then use the "Delete files" action and keep getting this issue: 

 

The execution of template action 'Apply_to_each_3' failed: the result of the evaluation of 'foreach' expression '@items('Apply_to_each')' is of type 'Object'. The result must be a valid array.

 

When I am trying to delete the files, it creates Apply to each loops automatically and then runs this error.  Is there a way I can fix this?

  • revolutionenerg Profile Picture
    21 on at
    Re: The execution of template action 'Apply_to_each_3' failed: the result of the evaluation of 'foreach' expression '@items('Apply_to_each')' is of type 'Object'. The result must be a valid array.

    That worked, thank you!

  • Verified answer
    v-xiaochen-msft Profile Picture
    on at
    Re: The execution of template action 'Apply_to_each_3' 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 @revolutionenerg ,

     

    Please try this:

    vxiaochenmsft_0-1679622311410.png

    item()?['{Identifier}']
     
    Best Regards,
    Wearsky
  • revolutionenerg Profile Picture
    21 on at
    Re: The execution of template action 'Apply_to_each_3' 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 there,

     

    Here it is:

     

    Screenshot 2023-03-23 080432.png

     

    The subtract expression in the filter array is to figure out which files were created more than 15 days ago

  • v-xiaochen-msft Profile Picture
    on at
    Re: The execution of template action 'Apply_to_each_3' 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 @revolutionenerg ,

     

    Please provide the screenshot of your flow.

     

    Best Regards,

    Wearsky

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

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!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1