• Ajith Madathil

How to restore a previous version of a Sharepoint document using Power Automate

Updated: Apr 1






A SharePoint Document Library provides a secure place to store files where you and your co-workers can find them easily; work on them together and access them from any device at any time.



Restoring a previous version of a document using Sharepoint


First lets see how we would do this in Sharepoint. We would go to the document library, select the file and then choose ‘Version history’.



Then we would select the correct version to restore to and select Restore. Easy.



Now, how can we do this using only Power Automate?


First, we will use the Sharepoint API to grab a list of the versions of the document.


The URL https://{{yoursharepointsite}}/_api/Web/GetFileByServerRelativePath(decodedurl=’/edu/Portal/Ideas/tips.txt’)/Versions is the one we need to hit.


In this URL, ‘edu’ is my SharePoint site, ‘Portal Ideas’ is the library name and 'tips.txt' is my document.


We use an HTTP request to call this URL.



And then we will use a Parse JSON action to unpack the results.


The easiest way to get the property name that we require is to execute the flow step (Send an Http Request to SharePoint), look at the run history and copy the JSON in to the below step (Parse JSON).


We setup a variable Comment which is taken from the VersionLabel property in the JSON.



Now, to actually restore the document to a previous version we will use SharePoint API again. This time we are calling this URL:


https://{{yoursharepointsite}}/_api/Web/GetFileByServerRelativePath(decodedurl=’/edu/Portal/Ideas/tips.txt’)/Versions/restoreByLabel({{Comment variable from above action}})




Hope this was useful.

34 views

Recent Posts

See All

The Compose action

Microsoft Power Automate (aka Microsoft Flow) provides lots of action steps out of the box. My favourite one is Compose. What does it do? What is the Compose action? The Compose action is like a stati

Blog Categories
 

Beginner

Intermediate

 

Advanced

Power Automate Essentials

How can I help you?

I am happy to help at any time.  You can contact me via the official PowerAutomate community forum.  Tag me (@abm) on any post you make there if you would like to me take a look at it.

I am always available for both corporate training or 1-2-1 training for individuals. 

© 2023 by Walkaway. Proudly created with Wix.com

  • Twitter Black Round
This site was designed with the
.com
website builder. Create your website today.
Start Now