Skip to main content

Notifications

Community site session details

Community site session details

Session Id : E6FODwRpROmWa5/ElRC1gv
Power Automate - Building Flows
Answered

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

Like (0) ShareShare
ReportReport
Posted on 23 Mar 2023 17:30:40 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. 

  • berebel Profile Picture
    45 on 10 Jan 2024 at 20:28:22
    Re: Delete items from a SharePoint list that are more then a year old

    Thank you very much

    Yes... addDays(utcNow(),-365,'yyyy-MM-dd') this worked for me.

  • Verified answer
    LR8 Profile Picture
    53 on 21 Aug 2023 at 16:47:02
    Re: Delete items from a SharePoint list that are more then a year old

    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.

     

     

  • David_MA Profile Picture
    10,624 Super User 2025 Season 1 on 29 Mar 2023 at 17:26:16
    Re: Delete items from a SharePoint list that are more then a year old

    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.

  • LR8 Profile Picture
    53 on 29 Mar 2023 at 14:36:11
    Re: Delete items from a SharePoint list that are more then a year old

    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
    10,624 Super User 2025 Season 1 on 24 Mar 2023 at 15:29:09
    Re: Delete items from a SharePoint list that are more then a year old

    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 24 Mar 2023 at 13:48:36
    Re: Delete items from a SharePoint list that are more then a year old

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

  • David_MA Profile Picture
    10,624 Super User 2025 Season 1 on 23 Mar 2023 at 17:55:26
    Re: Delete items from a SharePoint list that are more then a year old

    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.

     

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard
Loading started