Automations 2 min

Automatic archiving of SharePoint documents with Power Automate

Short answer

Managing documents in SharePoint can quickly become disorganised, especially when documents are no longer actively used over time. In this article you will learn how to set up automatic archiving for SharePoint documents using Power Automate.

Managing documents in SharePoint can quickly become disorganised, especially when documents are no longer actively used over time. In this article you will learn how to set up automatic archiving for SharePoint documents using Power Automate.

Managing documents in SharePoint can quickly become disorganised, especially when documents are no longer actively used over time. In this article you will learn how to set up automatic archiving for SharePoint documents using Power Automate. This helps BI teams streamline their document management and ensures better organisation and compliance with retention policies.

What you need

  • A SharePoint document library with documents that need to be archived

  • An archive folder or library within SharePoint to which documents will be moved

  • A Power Automate flow with access to the SharePoint connector

  • A criterion for archiving, for example documents older than a certain date or with a specific status

Step 1: Set up a trigger for periodic checking

The first step is to set up a trigger that activates the flow periodically, for example weekly or monthly. This ensures the flow automatically checks which documents meet the archiving criterion.

In the Power Automate portal, use the trigger “Schedule - Recurrence”. Set the frequency to, for example, 1 week and the start time as desired.

Step 2: Retrieve documents that meet the archiving criterion

Add an action “SharePoint - Get items” and configure it to retrieve documents from the relevant document library. Use a filter query to only retrieve documents older than, for example, 1 year. This can be done with an OData filter such as:

Modified lt '@{addDays(utcNow(), -365)}'

This retrieves only documents that were last modified more than 365 days ago.

Step 3: Move documents to the archive folder

Use an “Apply to each” action to loop through the retrieved documents. For each document, add the action “SharePoint - Move file”. Set the source URL and file name based on the dynamic content of the retrieved item. Choose the archive folder or library as the destination.

This ensures that all selected documents are automatically moved and archived.

Tips & common mistakes

  • Make sure the archive folder has sufficient permissions for the flow to move files.

  • Test the flow first with a small dataset to prevent accidental loss of documents.

  • Use clear naming conventions in the archive folder to make documents easy to find.

  • Note that moved documents are no longer available in the original library, which can impact ongoing processes.

Example: Archiving old project documents

Suppose you have a SharePoint library with project documents. With this flow you automatically archive all documents that have not been modified for more than a year to a separate archive library. This keeps the active library organised and old documents are safely stored.

Conclusion

With this automatic archiving of SharePoint documents in Power Automate you keep your SharePoint document management efficient and organised. Set this up easily via the Power Automate portal and optimise your work processes.

Our tip: Always test the archiving flow first with a small test library before running it on your production environment. Make a copy of a few documents in a test folder and check whether the flow correctly moves them to the archive folder. This prevents active documents from being accidentally archived and disruptions to ongoing processes.

Frequently asked questions

How do I set up automatic archiving for SharePoint documents?

In Power Automate, create a new flow with the 'Schedule - Recurrence' trigger so the flow periodically checks which documents need to be archived. Then add the 'SharePoint - Get items' action with an OData filter query to retrieve documents older than a certain number of days. Next use an 'Apply to each' action to move each found document to the archive folder via the 'SharePoint - Move file' action. Set the source and destination based on dynamic content from the previous step.

Which OData filter do I use to retrieve old SharePoint documents?

Use the following OData filter in the 'SharePoint - Get items' action to retrieve documents that have not been modified for more than a year: Modified lt '@{addDays(utcNow(), -365)}'. Adjust the number -365 to the desired number of days. This ensures that only documents older than the specified period are retrieved and moved to the archive folder.

What are common mistakes with automatic archiving in Power Automate?

A common mistake is that the archive folder has insufficient permissions for the flow to move files. Check the permissions of both the source library and the archive folder. It is also important to test the flow first with a small dataset, so you don't accidentally archive active documents. Also note that moved documents are no longer available in the original library, which can disrupt ongoing processes. Use clear naming conventions in the archive folder to make documents easy to find later.

Want a dashboard or automation built for you?

Stuurboard BI builds custom Power BI dashboards and workflow automations. Pragmatic, fast, and without the fuss.