PowerApps Forms defaulting to the first item in a SharePoint List after Submission?

I recently came across a weird issue in PowerApps, which I figured I'd share.

I had a PowerApps form, sitting over a SharePoint Data List. Pretty standard stuff right there.

Now, as part of the business process for the Form, a new Item is created in the SharePoint List using the Form, and the Form is immediately submitted to get a SharePoint List Item ID. The Form is NOT reset or hidden, which allows the user to continue to working on the Form to update the newly created SharePoint List Item.

What I was finding was that after that initial submission, the properties on the Form were resetting themselves to the FIRST item in the SharePoint list, overwriting the data entered by the user.

Took me a bit of head-scratching before I realised the problem is actually in the "Item" property of the Form itself.

By default, the PowerApps Form gets created with its Item property thus:


If(IsBlank(SharePointIntegration.Selected) || IsEmpty(SharePointIntegration.Selected),First([@Actions]),SharePointIntegration.Selected)

Now, the bit in Red is the cause of the problem; it's basically telling PowerApps "hey, if the SharePointIntegration object is empty, default the Form to the first item in the underlying data list" - hence my problem above!

Now, if we change the Item property for the Form so that the bit in Red above is changed to the bit in green below:

If(IsBlank(SharePointIntegration.Selected) || IsEmpty(SharePointIntegration.Selected),SharePointForm1.LastSubmit,SharePointIntegration.Selected)

.... we are telling PowerApps "hey, if the SharePointIntegration object it empty, default to the last submitted item for the Form"; ... and that's it! Problem sorted! I can create new PowerApps Forms, submit the form to get an ID, and continue working on the same form to update the newly created item.

Simple but effective. Hope this stops someone else scratching their head for a while :-)

33 views0 comments