Showing results for 
Search instead for 
Did you mean: 
New Member

Gallery selection resets to first item when using Patch and Search with Sharepoint list

Hi all,


I was hoping to get your thoughts on an issue that I have not been able to resolve these last few days.


Let me explain:


1) I created a Gallery control (Gallery_List) using data from a Sharepoint list:



2) I also created a TextInput control, which displays data from the selected item in the Gallery:



3) I then added a Patch to the OnChange property of this TextInput control so that I can edit the selected entry in the Sharepoint List:



Up until here, everything works as I would expect, no issues. The Sharepoint lists updates correctly, the Gallery control refreshes correctly and the selected item in the Gallery is still the item that I selected and the one on which I made the changes using the TextInput control.


4) I then added a TextSearchBox control, so that I can search within the "Title" column of the Sharepoint data. I therefore changed the Items property of Gallery_List to:



Now, everything still works as it should, however once I change the value in the TextInput control, the selected item in the Gallery gets automatically reset to the first item. The problem is that I want it to stay on the actual selected item on which I made the changes. And I cannot figure out how to do it...


5) I tried to use the Default property of the Gallery_List. I therefore changed the OnChange property of the TextInput control to create a variable for the ID of the selected item:



6) Then I changed the Default property of the Gallery_List:



The problem is that now it seems that the Gallery_List does not have any selection, and my TextInput control is blank...


Would you have any ideas on how to solve this?


Many thanks in advance.



Community Champion
Community Champion

You can get the last saved item id by Collection.LastSubmit.ID and use this item to select automatically

New Member

Thanks StalinPonnusamy.


I have created a form with 1 DataCardValue for the SPData field I want to update. I have changed the DataCardValue OnChange property to submit the form, and then changed the Default property of Gallery_List to:



And I am afraid it still does not work (exact same issue as when I was using Patch). Once the form is submitted, the Gallery_List does not have any selection anymore, and the Form controls are blank.


Any other ideas?

Helpful resources

PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,650)