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 / Restore list items ver...
Power Automate
Unanswered

Restore list items version history in bulk

(1) ShareShare
ReportReport
Posted on by 405

Hi all, 

 

Has anyone been able to figure out a way to restore the version history to a specific date of SharePoint list items? I had a flow which updated a column and mistakenly updated an additional column, and I need to restore the version history for each of the list items, but didn't want to have to do it manually. There are about 500 items. 

 

Any help is greatly appreciated. 

 

Thanks

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @_sourcecod3_,

     

    You could use the restoreVersion method of the Graph API.

     

    First you can retrieve all items. After that you can loop through the version history of every single item and find the correct version with a $filter based on the Created field. With the VersionLabel field value you can restore that item version.

     

    Below is an example how this might be possible.

     

    This is a very basic setup as a proof of concept. I would definitely recommend to first test it in a test list before you run it in your production list

     

    1. The First Send an HTTP request (Office 365 Groups connector) just retrieves the items

     

    https://graph.microsoft.com/v1.0/sites/@{variables('SiteId')}/lists/@{variables('ListID')}/items

     

     

    2. I used a Send an HTTP request to SharePoint action to filter between 08:16 and 08:17 of a certain day. You can adjust that to your specific date. 

    Btw, I just used the SharePoint action because the response and filtering was just a bit easier compared to the response of the Graph API (weirdly).

     

    _api/web/lists(guid'@{variables('ListID')}')/items(@{items('Apply_to_each')['ID']})/versions?$filter=(Created ge datetime'2022-09-10T08:16:57.000Z') and (Created le datetime'2022-09-10T08:17:12.000Z')&$select=Created,VersionLabel,VersionId

     

     

    3. Use another Send an HTTP request to POST with the restoreVersion method

    In the URI I am using the first version it found from the previous action and return the VersionLabel.

     

    https://graph.microsoft.com/v1.0/sites/@{variables('SiteId')}/lists/@{variables('ListID')}/items/@{items('Apply_to_each')['ID']}/versions/@{body('Send_an_HTTP_request_to_SharePoint_-_GetVersion')['value'][0]['VersionLabel']}/restoreVersion

     

     

    restoreitems_graphapi.png

  • _sourcecod3_ Profile Picture
    405 on at

    Hi @Expiscornovus ,

     

    Thanks for your response. This is very helpful, but I seem to keep running into an 'Access Denied' issue on restoring the version.

    I changed my filter in the SP REST Api call to retrieve a specific version and it works, but in restoring the version from the results I get an access denied msg.

    Below is my flow:

    errorMsg.png

     

     

    the expression you have on your restore version history request did not work for me, I kept getting 'value' is not a property in the results. So I changed it to this and this is when i get the access denied msg.

     

    FlowImg.png

     

     

    Any clues as to why I'm getting that? I do have SCA access to the site.

     

    There's a specific version I need to restore the items to.

     

    Thanks

     

  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @_sourcecod3_,

     

    In the Send an HTTP request I was using different Headers (application/json;odata=nometadata for both Accept and Content-Type headers).

     

    Can you use the same Headers to see if that makes a difference? I expect with those Headers it should be able to find the value field and you could also use the expression below:

    body('Send_an_HTTP_request_to_SharePoint')['value'][0]['VersionLabel']
  • _sourcecod3_ Profile Picture
    405 on at

    Hi @Expiscornovus 

     

    Cant believe i missed the headers. I've added them and now the URI path works on the restore version action, but It's giving me again the 'Access Denied' error message.

     

    updated.png

     

    error message:

     

    newErr.png

     

    Any other ideas?

  • _sourcecod3_ Profile Picture
    405 on at

    So it looks like my account doesn't have the proper permissions to restore versions.

    Do we know what kind of permissions and where do apply these permissions?

     

    graphErr.png

  • pwwuk Profile Picture
    2 on at

    I'm falling at the first hurdle .. I've got the Site ID using: 

     

    https://graph.microsoft.com/v1.0/sites/{mydomain}.sharepoint.com:/filing?$select=id

     

    I get an different Site ID using 

    https://{domain}.sharepoint.com/{site}/_api/web

     

     And List ID using 

     

    https://{mydoamin}.sharepoint.com/{site}/_layouts/15/listedit.aspx?List=%7B???????????????????%7D

    where the ?????? = list GUID 

     

    using all and every comdination I get 

     

    "The specified list was not found"
     
    When running the flow. 
     
    Any input appreciated 🙂 

     

     

     

     

     

     

     

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 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard