There is no action in Flow yet to access the version history of SharePoint list items (or documents). So how can we get to older versions of a list item in Flow, including all the old column values? A customer asked today if there is a way to use a flow to see if a certain column has changed (when an item changes), and then … do things.
Luckily, we have everything we need to accomplish this with the help of our best friend: send an HTTP request to SharePoint SharePoint is the intranet solution from Microsoft. SharePoint Online SharePoint online (SPO) is usually included in your Microsoft 365 subscription, but can also be purchased directly. SharePoint Online has the advantage that there is no need to operate a separate server, but it lacks the customization options of a self-hosted installation of SharePoint.Although SharePoint Online is limited to core functions....
Here are the main steps:
Trigger for an element created by changed, add trigger condition so that it is not triggered when created (as this triggers unnecessary runs)
Calculate the previous version number so we know which version to look for
Retrieve all SharePoint
SharePoint is the intranet solution from Microsoft. SharePoint Online SharePoint online (SPO) is usually included in your Microsoft 365 subscription, but can also be purchased directly. SharePoint Online has the advantage that there is no need to operate a separate server, but it lacks the customization options of a self-hosted installation of SharePoint.Although SharePoint Online is limited to core functions... list item versions from SharePoint
SharePoint is the intranet solution from Microsoft. SharePoint Online SharePoint online (SPO) is usually included in your Microsoft 365 subscription, but can also be purchased directly. SharePoint Online has the advantage that there is no need to operate a separate server, but it lacks the customization options of a self-hosted installation of SharePoint.Although SharePoint Online is limited to core functions... using the HTTP request
Analyze the result (JSONJavaScript Object Notation is abbreviated as JSON. JSON is programming language independent and compact. We use JSON code to format SharePoint online:Show search results mehr erfahren) from SharePoint
SharePoint is the intranet solution from Microsoft. SharePoint Online SharePoint online (SPO) is usually included in your Microsoft 365 subscription, but can also be purchased directly. SharePoint Online has the advantage that there is no need to operate a separate server, but it lacks the customization options of a self-hosted installation of SharePoint.Although SharePoint Online is limited to core functions...
Loop all versions and drag out the desired version (previous version)
Do things.
Configure the trigger with condition
First go to the trigger step settings:
Then add the following condition to ensure that the flow is only executed if the version is NOT 1.0:
not(contains(triggerBody()?[‘{VersionNumber}’],’1.0′))
Calculate the previous number
The next step is to calculate the previous number using a “Compose” action. We can do this by using the sub expression with a nested int
An integer stores whole numbers. So no decimal places :-) You can find more information here at Wikipedia: https://de.wikipedia.org/wiki/Integer_(Datentyp) function to convert the version number to an integer
An integer stores whole numbers. So no decimal places :-) You can find more information here at Wikipedia: https://de.wikipedia.org/wiki/Integer_(Datentyp) (so that ‘sub’ gets two integers to work with). And then we simply add “.0” after the expression to get the correct format (“2.0” and not just “2”).
sub(int(triggerBody()?[‘{VersionNumber}’]),1)
Call up SharePoint
SharePoint is the intranet solution from Microsoft. SharePoint Online SharePoint online (SPO) is usually included in your Microsoft 365 subscription, but can also be purchased directly. SharePoint Online has the advantage that there is no need to operate a separate server, but it lacks the customization options of a self-hosted installation of SharePoint.Although SharePoint Online is limited to core functions... and retrieve the version history of the SharePoint
SharePoint is the intranet solution from Microsoft. SharePoint Online SharePoint online (SPO) is usually included in your Microsoft 365 subscription, but can also be purchased directly. SharePoint Online has the advantage that there is no need to operate a separate server, but it lacks the customization options of a self-hosted installation of SharePoint.Although SharePoint Online is limited to core functions... list
To get the version of our list element, we call HTTP and pass the ID of the list element. Note that the title of the list is the display name and not the system name / URLA Uniform Resource Locator identifies and locates a resource, for example a website, via the access method to be used and the location of the resource in computer networks.. Even if you were a good developer and gave the list the system name “catvisitorslog” to get a nice and clean URLA Uniform Resource Locator identifies and locates a resource, for example a website, via the access method to be used and the location of the resource in computer networks., the HTTP call wants “cat visitors log”.
Analyze the JSONJavaScript Object Notation is abbreviated as JSON. JSON is programming language independent and compact. We use JSON code to format SharePoint online:Show search results mehr erfahren result
This is a little trickier if you have not worked with JSONJavaScript Object Notation is abbreviated as JSON. JSON is programming language independent and compact. We use JSON code to format SharePoint online:Show search results mehr erfahren before. Before you add the action itself. Save the flow and execute it to test whether the HTTP call to retrieve versions works. Then copy the entire JSONJavaScript Object Notation is abbreviated as JSON. JSON is programming language independent and compact. We use JSON code to format SharePoint online:Show search results mehr erfahren block from the body section under the outputs:
Then go back to edit the flow and add the Analyze JSONJavaScript Object Notation is abbreviated as JSON. JSON is programming language independent and compact. We use JSON code to format SharePoint online:Show search results mehr erfahren action. Add the output text from the “Get versions” HTTP call as content and then click “Use sample payload…” to paste the JSONJavaScript Object Notation is abbreviated as JSON. JSON is programming language independent and compact. We use JSON code to format SharePoint online:Show search results mehr erfahren code you just copied. This tells the flow what the data structure looks like and how it is analyzed.
Loop all versions and … do stuff Our final step is to go through the versions we just analyzed, determine which version we want to pull, and then do something. In this example, I save the value of the “Office location” column to see where something has moved. First create an Apply for each and specify the results from the “Parse VersionHistory from JSON”, as this contains all our versions. Then add a condition that takes the VersionLabel from the looped element (under “Parse VersionHistory from JSON”) and compare it with the output of the previously created “Calculate PreviousVersionNumber” step. This checks each loop for the version The number of the loop is in fact the previous version we want to target. For example, if there are 4 versions of the element, version 1.0, 2.0 is run through and validated as false. However, when it gets to 3.0, it becomes true on validated and we can start working our magic! In this example, I only grab the value for office location and save for further logic. So if you run it, you will get the location value:
Source: https://www.catapultsystems.com/blogs/get-previous-versions-of-sharepoint-list-items-in-flow/
Dieser Beitrag ist auch verfügbar auf: Deutsch (German)