Power Apps SharePoint list item version history coding example

Power App version history for SharePoint list item coding example

Retrieving the SharePoint list item version history from a Power App is not straightforward, as there is no ready-made component to handle this complex task.

However, we managed to make it work. Check out the images below to see how it looks. At the bottom of this post, you can download the app and the flow.

The “Version History” button triggers a Power Automate flow, which retrieves the versions from the currently open SharePoint Online list item on the screen.

Power App version history

The version can be viewed, but the restore option is not operational yet. Restoring versions has proven to be quite complex.

Power App version history - restore an older version

So, how did we accomplish this? First, credits to this post, which was our starting point.

The code behind the button “Version History” is listed below

Set(
varVersionHistory,
versionHistory.Run(varCurrentItem.ID).history
);
Clear(colHistory);
ClearCollect(
colHistoryTemp,
Split(
TrimEnds(varVersionHistory),
"|"
)
);
ForAll(
colHistoryTemp,
Collect(
colHistory,
{
Date: DateTimeValue(
First(
Split(
Value,
";"
).Value
).Value,
"nl-NL"
),
Version: Last(
FirstN(
Split(
Value,
";"
).Value,
2
).Value
).Value,
Editor: Last(
FirstN(
Split(
Value,
";"
).Value,
3
).Value
).Value, 
ContractID: Last(
Split(
Value,
";"
).Value
).Value
}
)
);
RemoveIf(
colHistory,
IsBlank(Version)
);
Sort(
colHistory,
Date,
SortOrder.Descending
);
Clear(colHistoryTemp);
If(
varClearHistory = "1",
Set(
varClearHistory,
""
)
);

Screen captures of the Power Automate form version gallery:

Power App version history form design

Power App version history form design 2

Screen captures of the Power Automate flow to retrieve the SharePoint Online list item versions:

Power App version history get version item flow example

Power App version history version log access SharePoint online list

We hope this information is sufficient for you to recreate this functionality in your Power App.

ShareFlex

As an alternative, please check out how the versions of a SharePoint list item are presented in Shareflex:

Power App version history - shareflex exmaple

The users have the possibility to view each version and to restore a particular version of a SPO list item.

Power App version history shareflex version log report

The same control is available for SharePoint Online Libraries, as shown in the image below.

Concluding

PortalSystems, the company behind Shareflex, invested significant effort in developing the SharePoint List item and Library version history control. The question remains: how much effort will it take to create something similar in Power Apps?

Is a low-code platform too simplistic for achieving this level of functionality?