web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / onselect in gallery
Power Apps
Unanswered

onselect in gallery

(1) ShareShare
ReportReport
Posted on by

We have a problem with OnSelect of a gallery.  This app was built a long time ago and I have to work with it.

 

Basically we have two galleries, one is to display data, and another is on another screen with the ability to update/delete/add the data. 
These two galleries are using two different collections for the data.

In the second screen gallery to update the data, there is a patch() function in OnSelect.  Basically if there are change to the entries in this gallery, patch works with its collection to update or add new entries.  

 

What seems to be happening is created a function in the first gallery to duplicate data.  I add the data to its collection and it seems fine.  However, when I click to move to the second gallery, that is for update/delete/add, its Patch function inside OnSelect seems to execute and adds a bunch or repetitions of the duplicate line I added in the first gallery.  

so if this is confusing.  Even I'm confused.

 

Basically the second screen for update/delete/add has Clear and ClearCollect to recollect for the gallery and the data is fine, but when this second screen and gallery loads the Patch in OnSelect seems to execute and adds a bunch of repetitions in its collection?  Like if I added one entry, there is that entry, and another 4 more repetitions of that entry.  Which if we submit the form then these repetition entries and entered the sharepoint library.  that sucks.

 

I even put a test collection in the OnSelect of gallery like ClearCollect(whatisgoingon, ThisItem) and I can see that on load of this screen and gallery whatever is in OnSelect executes.  Why?  I didn't select any entries!?
I do not understand why it executes AND then adds multiple repetition of the entry or entries I added.  I understand why they put the patch there in OnSelect, because they want to patch "ThisItem", but why does it run on load?

 

Here is an idea of the code
second screen on visible has:
Clear()
ClearCollect(secondcollecction,Filter(table, ID = whatever))

and in the second gallery's OnSelect this is the patch:

Patch(
 secondcollection,
 ThisItem,
 {
 Title: txtSAFProject.Text & "_" & cboSAFType.Selected.Value & "_" & cboSAFFY.Selected.Value,//txtSAFTitle.Text,
 SAFType: cboSAFType.Selected,
 FY: cboSAFFY.Selected,
 ProjectPhase: cboSAFProjectPhase.Selected,
 ProjectID: Value(txtSAFProjectID.Text),
	 Project: txtSAFProject.Text,
 SAFAmount: Value(txtSAFAmount.Text)
 }
);

 

Categories:
I have the same question (0)
  • jrletner Profile Picture
    720 Moderator on at

    @gstlouis I'm sure you're looking into this but:

    • Check if there are any other triggers (such as OnVisible or OnStart) that might be causing the Patch function to execute during gallery load
  • jrletner Profile Picture
    720 Moderator on at

    @gstlouis I would suggest using the code search feature in PowerApps to try and find some other location within your application that is calling that gallery's onselect property. It could be hiding anywhere.

     

    Search for:   Select(theGalleryName) or even a Select(Parent) somewhere else in your gallery. Could be hidden in a hover property too.

     

  • gstlouis Profile Picture
    on at

    Thanks for the note.  I've looked pretty hard for strange things that could trigger this onselect gallery.  In the OnSelect I've put in Notify("what is going on") and every time I load this screen it triggers.  So it is more like something is triggering this gallery's on select on load and I do not understand why.  There is nothing out of the ordinary onVisible of this screen.  I just do not know why it triggers.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 379 Most Valuable Professional

#2
11manish Profile Picture

11manish 203 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard