Archiving documents nowadays is one of the important tasks which many of the people do on the day to day activities either in SharePoint or using some other software in order to use it for future reference. Many of you might think how this can be done in the SharePoint library. It is a very simple task before going into the implementation. Let me explain to you the user case which we are going to implement, usually there will be an approval process followed in all the organization before releasing the document to the larger audience. The case is similar to that once the document is approved a copy of the document is stored in another document library where it is used for reference as well no versioning of the document will be maintained there and that document will be considered as the final document to be released for the larger audience.
Pre-requisites:
We need “2” – SharePoint libraries say library 1 and library 2.
Step 1 – Create a SharePoint library and create one custom column “Status “which would be a choice column with values “In-Progress”, “Approved”, “Rejected”, “Archived”
Step 2 – We can create a flow by directly opening Power Automate (https://powerautomate.com/ ) or directly opening from the list / library.
To open from the list/library select the Automate option from the ribbon → Create a flow
Once you click on create a flow a small box opens in the right side, scroll down and click more it redirects to the flow page
from New select the template Automated-from the blank
Step 3 – Select the action “On selected item“ Select the site address, list name and the view name from the drop down.
Step 4 – Get the properties of the selected file using Get files (properties Only ) action and filter the document using the id i.e., ID eq ‘ID’ as shown below and then select the view from which this item fetches the data.
Step 5 – Check the condition if the document status is not equal to “In-Progress” and not equal to “Archived”. If this condition matched, then the document would be archived.
Expression:
body(‘Get_files_(properties_only)’)?[‘value’]?[0]?[‘DocumentStatus’]
Or we can use the value from the get properties only i.e., directly the column value as “Document Status”
Step 6 – Update the status of the document once the condition is matched. The status would be updated as “Archived”.
Note – In order to view all the Archived documents, you can create a new view for the SharePoint.
As many of you know creating view is a easy process just going to list settings at the bottom we have option to create a new view click create view and select the default view which is already present so that all the columns will be checked and in the filter condition update the condition as Document status equals to Archived.
Step 7 – In order to delete the documents from library 2, Select the action “Deletes the file specified by the file identifier”
File Identifier value should be given in the below format such that it concatenates the document with the proper extension
replace(concat(‘/Library2/’,body(‘Get_Document_file_properties’)?[‘{FilenameWithExtension}’]),’/’,’%2F’)