Forum Discussion
Limit and Archive off more than 3 Entries per Unique ID
but why can't you just keep only 243 items in the list and update every item if the location changes instead of creating a new item?
Then you can access the history of every item through the version history.
- SvenSieverdingDec 01, 2022Bronze Contributor
jamescosten
It is a little bit more complex in Powerapps to get the version history from SharePoint.You don't get the version history directly from your datasource, so you need to create a PowerAutomate Flow that fetches the history data for a given item and then dispays it.
The idea is that you have a button in your gallery that opens a new screen.In the "On visible" Method of that screen you call a PowerAutomate Flow and pass the SharePoint Item ID.
The Flow uses the "Send an HTTP request to SharePoint" Method to get the Url
https://<tenant>.sharepoint.com/sites/<SITE>/_api/web/lists/GetByTitle('<LISTNAME>')/items(<ID>)/Versions
Now you have the versioning data and need to do some formatting to pass it back to PowerApps
In PowerApps you collect the data into a new collection and display that data in a gallery on the new screen.
So with screenshots:
First make sure that you have "Parse Json" function turned on in "Upcoming Features"
Then create a new flow in your powerapp and call it "ItemVersionHistory"
Use this uri_api/lists/GetByTitle('<Listname>')/items(<itemID>)/versions
Use this formular in the response-actionstring(outputs('Send_an_HTTP_request_to_SharePoint')?['body']['value'])
Then, in powerapps, in the "OnVisible" property of the item details screen enter thisClearCollect( versions, ForAll( Table(ParseJSON(ItemVersionHistory.Run(BrowseGallery1.Selected.ID).result)), { Version: Text(Value.VersionLabel), Editor: Text(Value.Editor.LookupValue), MyField1: Text(Value.MyField), MyField2: Text(Value.MyField) } ) )
You get a new collection "versions" containing all item versions.
If you have custom fields in your SharePoint list (i think you have at least a custom location column) you can get the values for these fields on the time of the version like i got them in Line 8&9
Add a new gallery to your details screen and display the versions there.