cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mgodby
Post Patron
Post Patron

Gallery.Selected changes when I do a SubmitForm

Why does my Gallery.Selected change when I do a SubmitForm? I've noticed that this issue only occurs when my gallery is sorted. Is there a way to stop this? Is there a way to prevent my gallery from resetting when I do a SubmitForm?

When the "Items" for my gallery is this ...
sorteditems.png

... the issue occurs, but when I remove Sort(), I don't get the issue.

notsorteditems.png

 

6 REPLIES 6
PowerAddict
Super User II
Super User II

Try this:

1. Set the OnSelect property of the gallery to Set(currentRecord, ThisItem)
2. Set the Default property of the gallery to currentRecord.

Let me know if this helps.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit Bhatia
https://www.thepoweraddict.com

No it didn't work for me. The selected item just goes blank after I do a submitform. I tried setting it up another way and checked the "currentRecord" data and see that it is indeed set to the one I selected before, but for some reason the gallery.selected goes back to it's first item. Like the "currentRecord" has the item 1075 in its data but the gallery.selected is for 1076. 

A few questions:

1. Is your form on another screen?
2. Are you simply editing the selected record in the form?
3. What exactly did you try when you set it up differently? As long as you have something defined in the Default property of the gallery, it shouldn't default to the 1st one. Try once with setting the Default property to {} to see if it blanks out Gallery.Selected instead of setting it to the 1st item.
4. Lastly, where you have the SubmitForm function (possibly on the OnSelect of a button), try adding this:
SubmitForm(Form1);Reset(Gallery1)

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit Bhatia
https://www.thepoweraddict.com
rebeccas
Super User
Super User

Gallery.Selected is always causing problems for me so I just don't use it.

 

Instead in the gallery do OnSelect=Set(varSelected, ThisItem.Title) and then for the Form you can have on the Items=LookUp(DataSource, Title=varSelected)  and you can also filter other Galleries off that or use it however you need. It is a global variable then so works across screens and won't change what is selected off of other actions. If you Title field isn't unique do the ID or something else instead...a unique value.

I had the same problem and @rebeccas solutions worked fine for me!

@pewil 

I agree with the above but use Lookup(SPlist, ID=Gallery1.Selected.ID) as the Item prpropriety of the form. This guarantees a unique value is used for finding the correct record.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (19,237)