Nov 29 2022 06:37 AM
I have a sharepoint list that is tracking locations as we scan objects. I have a history tab and to ensure thte tablet doesnt slow to a crawl or crash I'd like to limit the entries per unique ID to 3 per and send the rest to archive list i have set up.
For examplete: Item 1 is scanned 5 times but i only want the most recent 3 scans to show and the archive list to show 2 entries.
Nov 30 2022 07:07 AM
Nov 30 2022 10:54 PM
You could create a PowerAutomate flow that does the following:
But the requirements seem wierd to me, what exactly are you trying to accomplish with that setup?
Couldn't you just enable versioning on the list and then just update the same item with the unique ID every time you scan a new item?
Or group the list view by the unique ID?
Dec 01 2022 12:54 AM
Dec 01 2022 03:49 AM
Dec 01 2022 03:55 AM
Dec 01 2022 05:54 AM
@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-action
string(outputs('Send_an_HTTP_request_to_SharePoint')?['body']['value'])
Then, in powerapps, in the "OnVisible" property of the item details screen enter this
ClearCollect(
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.