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 items from a Sh...
Power Automate
Answered

Delete items from a SharePoint list that are more then a year old

(0) ShareShare
ReportReport
Posted on by 53

I am looking at creating a flow that once a month will delete items from my SharePoint list that are more then a year (I have a date out column that I want to use to determine the date)

 

Any help I can get would greatly be appreciated. 

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

    Since you already have a date field that you would like this to occur on, I would suggest that you use the built-in information management policies feature to delete the item based on that date field. You can read more about this feature and how to configure it at Create and apply information management policies - Microsoft Support

     

    It will look like this:

    David_MA_0-1679594074823.png

    Of course you do not need to use the declare record feature, which prevents the item from being deleted. And there is an option to Permanently Delete in addition to the Move to Recycle Bin option.

     

     

  • LR8 Profile Picture
    53 on at

    Thanks for the suggestion, unfortunately I don't have access to these setting.

  • David_MA Profile Picture
    12,982 Super User 2025 Season 2 on at

    In that case, using Power Automate is not too difficult. You would:

    1. Create a scheduled flow to run every 30 days.
    2. Use the Get files (properties only) action on the list with a filter query Created lt the current date -365:
      formatDateTime(addDays(utcNow(),-365),'yyyy-MM-dd')​Add a condition to see if any files met the criteria:
      length(outputs('Get_files_(properties_only)')?['body/value'])​Add an Apply to each with the Value from the Get items action
    3. Add a Delete file action configured with the identifier from the Get files action.

      Your flow will look like this. If you need to do this on a list, use Get items and Delete item.
      getfiles.jpg

    Note: you will probably want to add a condition in the apply to each to make sure IsFolder equals False and then put the delete action in the Yes side so it only deletes the item if it is not a folder. 

  • LR8 Profile Picture
    53 on at

    Thanks for your help but this did not work, I am working with a list and I did change to get items and delete items. When I tried adding the condition it told me it did not work (I changed Get_files_(properties_only to Get-Items but it still did not work)

     

  • David_MA Profile Picture
    12,982 Super User 2025 Season 2 on at

    Odd that it did not work. I just set up two workflows today with this type of filter and they worked without any issues. Is it generating an error message? If so, what is the error? In this flow I want everything where the status is active and it was created within the past seven days:

    filterqueryonlist.jpg

    This is the expression for the date field:

    addDays(utcNow(),-7,'yyyy-MM-dd')

    Note, it is important that the expression is within single quotes and the date is formatted as an ISO8601 date, which is the format shown in my expression. Any other date format will not work.

  • Verified answer
    LR8 Profile Picture
    53 on at

    Thank you for you help. It still did work for me but using your suggestions I was able to come up with something that did work for my.

     

    1. Created a scheduled flow that runs once a month
    2. added new step Get items from SharePoint (I had to use this because I was trying to get items from a list)Get Items.png
    3. Click on Show advanced options
    4. Under Filter Query I selected a date column from my list then selected "less then" and add the expression addDays(utcNow(),-365,'yyyy-MM-dd')
    5. Added new step Apply to each Apply to each.png
    6. For Select an output from previous steps value (there is only one choice under get items)
    7. Select Delete item

    I found this worked for me.

     

     

  • berebel Profile Picture
    45 on at

    Thank you very much

    Yes... addDays(utcNow(),-365,'yyyy-MM-dd') this worked for 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 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard