Skip to content

Manage version history in a SharePoint column using Power Automate

In this post, you will learn to capture previous versions of SharePoint columns and update it in a multiline of text field of SharePoint using power automate

My SharePoint List structure is as shown below

Column NameData TypeValue
ProductNameSingle line of text 
PriceNumber 
CurrencyChoiceUSD, INR, CAD
ManufacturedDateDate and Time 
IsProductInStockChoiceYes,  No
OldAndNewMultiline of text 

From Power Automate, Click on Automated Cloud Flow

Add a When an item is created or modified trigger. Select your site and list name there.

Click on Add an action and search for/select Get changes for an item or a file (Properties only).
Select the site address and the list name.
Add the Id from the trigger using the dynamic content.
Add the below expression under the Since column

triggerOutputs()?['body/{TriggerWindowStartToken}']

Add Send an HTTP request to SharePoint action. To get the version history add below expression

_api/web/lists/getByTitle('Products')/items(@{triggerOutputs()?['body/ID']})/versions(@{outputs('Get_changes_for_an_item_or_a_file_(properties_only)')?['body/SinceVersionId']})

Add a condition and check for the required columns changes.

If either column has changed, then update the Versions field with old value and new values.

Add below three blocks of code in the Versions column of sharepoint

You will get previous value of the version column by using below expression

body('Send_an_HTTP_request_to_SharePoint').d.OldAndNew

Using below code you will get the previous value

ModifiedDate: @{triggerOutputs()?['body/Modified']}
Old_ProductName:@{body('Send_an_HTTP_request_to_SharePoint').d.ProductName}
Old_Price:@{body('Send_an_HTTP_request_to_SharePoint').d.Price}
Old_Currency:@{body('Send_an_HTTP_request_to_SharePoint').d.Currency}
Old_ManufacturedDate:@{body('Send_an_HTTP_request_to_SharePoint').d.ManufacturedDate}
Old_IsProductInStock:@{body('Send_an_HTTP_request_to_SharePoint').d.IsProductInStock}

Using below code you will get the changed values

New_ProductName: @{triggerOutputs()?['body/ProductName']}
New_Price:@{triggerOutputs()?['body/Price']}
New_Currency:@{triggerOutputs()?['body/Currency/Value']}
New_ManufacturedDate:@{triggerOutputs()?['body/ManufacturedDate']}
New_IsProductInStock:@{triggerOutputs()?['body/IsProductInStock/Value']}

If you liked the post, please share it with others 🙂

Please feel free to comment if you are stuck in any step

Thank you for reading 🙂

Published inPower Automate