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 / Delete files after 3 d...
Power Automate
Answered

Delete files after 3 days - flow works except gives an error.

(0) ShareShare
ReportReport
Posted on by 10

I wrote a script in Power Automate to automatically delete files after X amount of days that the file was created.  It deletes the files, but gives an error:

tobrien1_0-1645472232306.png

 

This is what my flow looks like:

 

tobrien1_2-1645472382444.png

 

tobrien1_3-1645472453508.png

the Expression i'm using is adddays(utcnow(),-3,'yyyy-MM-dd') 

Categories:
I have the same question (0)
  • tobrien1 Profile Picture
    10 on at

    This is in the gov't cloud if that makes any difference

  • Verified answer
    ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    Can you post a screen shot of a run with the error that shows where the error happened.

    Also, you would be better of using a filter query rather than a condition - then just loop through and delete everything returned.  

    Filter query would look like this:

    Created lt 'addDays(utcNow(), -3,'yyyy-MM-dd')

     

    Finally, you don't need a Flow at all for this - SharePoint will do it for you automatically.  First, go to Site collection features and activate Library and Folder Based Retention Feature.  Then go to the library settings and click on Information management policy settings.  Click on Document and add a retention stage that deletes documents after a specified period of time.

     

     

     

     

  • tobrien1 Profile Picture
    10 on at

    I've tried it that way and again the files delete, but the same error message and failure point:

     

    tobrien1_0-1645475216768.png

     

    I did take your advice and turned on Library and Folder based features and set the retention, but i'd still like to know why my flow fails.  Thanks for your help.

  • ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    @tobrien1 

    Are all the files deleted that match your criteria even though you get the error or is it failing on a single file all the time?

     

  • tobrien1 Profile Picture
    10 on at

    All of the files that should be deleted are gone, so the flow works it's just the error that is bugging me.

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 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard