Forum Discussion
Nick
10 years agoFrequent Visitor
Getting SharePoint List items with full history version?
Hi, We do have a SharePoint list to manage Fleet inventory of asset: mainly their attribution (who own it) and their status (active, lost, broken, etc.). We did activated the SharePoint Version ...
JensG
6 years agoAdvocate II
Hi tdaskalakis,
here is an short example how to use the function:
1) Add an Query to your list where you want to see the version history:
let
Source = SharePoint.Tables("https://<yourDomain>.sharepoint.com/sites/<YourSPSite>", [ApiVersion = 15]),
#"Filtered Rows" = Table.SelectRows(Source, each ([Title] = "SampleList")),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Items", "Title"}),
#"Expanded Items" = Table.ExpandTableColumn(#"Removed Other Columns", "Items", {"Id"}, {"Items.Id"})
in
#"Expanded Items"2) Invoke the Custom Function "GetVersionHistoryFromSharePointList" (from post above)
3.) after the invoke your table will have the column version which contains an table which contains a table per version of the item.
4) expand the Table.
5) now you have all possible items in a list, now you can further expand specific columns as you need.
Example code after those steps:
let
Source = SharePoint.Tables("<Your SP Site Link>", [ApiVersion = 15]),
#"Filtered Rows" = Table.SelectRows(Source, each ([Title] = "SampleList")),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Items", "Title"}),
#"Expanded Items" = Table.ExpandTableColumn(#"Removed Other Columns", "Items", {"Id"}, {"Items.Id"}),
#"Invoked Custom Function" = Table.AddColumn(#"Expanded Items", "Versions", each GetVersionHistoryFromSharePointList([Title], "<Your SharePoint Site>", [Items.Id])),
#"Expanded Versions" = Table.ExpandTableColumn(#"Invoked Custom Function", "Versions", {"properties"}, {"Versions.properties"}),
#"Expanded Versions.properties" = Table.ExpandTableColumn(#"Expanded Versions", "Versions.properties", {"IsCurrentVersion", "VersionId", "VersionLabel", "Title", "ExampleText"}, {"Versions.properties.IsCurrentVersion", "Versions.properties.VersionId", "Versions.properties.VersionLabel", "Versions.properties.Title", "Versions.properties.ExampleText"})
in
#"Expanded Versions.properties"Anonymous
6 years agoNot applicable
Awsome! You made my day. Thanks a lot. 🙂