Retrieving Previous versions of a SharePoint Item

Posted by

Leveraging previous versions of items in SharePoint is not only a best practice but also a strategic advantage for organizations across various industries. Whether it’s ensuring document integrity, meeting compliance standards, facilitating collaboration, or enhancing decision-making, the ability to retrieve historical versions provides invaluable insights and empowers users to make informed choices.


SharePoint’s versioning capabilities are a fundamental aspect of its document management functionality, providing users with the ability to track, manage, and restore previous versions of documents, list items, and pages. This feature is invaluable for maintaining data integrity, supporting compliance requirements, facilitating collaboration, and enabling efficient document lifecycle management.

Use case

There are times when you want to compare the current value with the previous value in the SharePoint list item. This could be for audit purposes, or, for performing tasks such as triggering notifications, enforcing business rules, or tracking changes over time.

In this blog post, I’ll illustrate a method for comparing the current and previous values of a list item, focusing specifically on a list titled “Dogs.” Within this list, each item includes a “Title” column where the breed of a dog is stored. Importantly, versioning is enabled for this list, ensuring that changes made to items are tracked over time.

SharePoint List

Our objective here is to demonstrate how to retrieve the previous breed of a dog after an item has been updated.

The flow

My flow comprises of 6 action including the trigger.

  1. The trigger I used is When an item is created or modified.

2. Next, I get the current Version label of the modified item

3. I then use an expression to calculate the value of the previous version

The expression is

formatnumber(sub(float(outputs('Compose_-_Current_Version')), 1.0),'0.0')

4. Next, I use the HTTP action to fetch the details of the previous version.

The endpoint to get all versions of the item is:

_api/web/lists/GetByTitle('ListName')/items(itemID)/versions

The endpoint initially returns all versions available. However, as I specifically require only the preceding version, I have implemented a filter to refine the results accordingly.

_api/web/lists/GetByTitle('Dogs')/items('ID of the item from trigger')/versions?$filter=VersionLabel eq '@{outputs('Compose-_Previous_version')}'

5. The action above returns the details in JSON format. I then added a Parse JSON action for convenience.

6. Finally I used the expression below to list the previous version of the item.

first(body('Parse_JSON')?['d']?['results'])['Title']

7. The final step involves showcasing the “Current Title” of the item, allowing for a direct comparison with the output from the preceding action.

Entire Flow

Final Output

Leave a Reply

Your email address will not be published. Required fields are marked *