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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Gallery, set default s...
Power Apps
Unanswered

Gallery, set default selection to first item

(0) ShareShare
ReportReport
Posted on by 3,271

Hi,

I saw similar post about this, but for some reason I couldn't get this to work.

 

Is not a big deal but is annoying for the user:

 

I have two screens. in my first screen "welcome screen" I have a button that navigate to my second screen. In that screen I have my "BrowseGallery" and it show all the items from my Sharepoint list. but for some reason the first item is not selected by default so, a form besides my gallery shows empty or getting your data. And it show the data until someone click in a record in my gallery.

 

I have tried the default first(BrowseGallery)  and First(BrowseGallery.AllItems) and no results.

 

Any help please?

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @sajarac ,

    Try (the With() is only to avoid the Delegation Warning)

    With(
     {wList:YourListName),
     First(wList)
    ) 

    If this does not work immediately, add a reset to the gallery.

    Reset(GalleryName)

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • Sajarac Profile Picture
    3,271 on at

    Hi.

    Sorry. Didn't works 

    😞

  • Sajarac Profile Picture
    3,271 on at

    The error could be because I have the OnSelect property of my BrowseGalley = Set(varRecord,ThisItem)   ?

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @sajarac ,

    Yes that would be the case - the Default has to be compatible with the Items.

    Keep the Default code and do this on Gallery OnSelect 

    Set(gblID,ThisItem.ID)

    then the Item of your Form

    LookUp(
     YourListName,
     ID=gblID
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

  • Sajarac Profile Picture
    3,271 on at

    Hi @WarrenBelz , unfortunately nothing happens. Same behavior.

  • JacquesOlivier Profile Picture
    on at

    To add to @WarrenBelz's solution
    Add in the OnVisible property of the 2nd screen:
    Set(gblID, First(Gallery1).ID) where Gallery1 is the name of your gallery. 

     

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @sajarac ,

    I use that exact code myself on several galleries and it works as expected. Did you reset the gallery?

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @sajarac 

    As requested...

     

    So if you get rid of the Default property on your Gallery, does it then show the first item selected?  It should by default.  Then your Form Item property can simply be BrowseGallery.Selected

     

  • Sajarac Profile Picture
    3,271 on at

    Hi, @RandyHayes , thank you very much. Well I was trying to implement the Set(varRecord, ThisItem) Per Shane Young video recommendation. He says Gallery.Selected is a bad practice. But it has been a pain. Can't figure out.

     

    BTW. Gallery Default is empty.

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @sajarac 

    There is no need to not rely on the Selected Item property of the Gallery - UNLESS you have a complex formula in it.

    PowerApps will maintain the selected Item unless it need to re-evaluate the formula in Items.  It will need to re-evaluate when there are any data shaping functions being used or if there are sort functions being used.  Beyond that, you can rely on it.  If not, then yet, setting a snapshot variable will be necessary.

     

    However, there is a level beyond that...which is to completely discard the Selected functionality.  This would mean that you do not ever refer to the .Selected item of the Gallery ... including ThisItem.IsSelected.  In that case you would rely on your variable to determine the selection.

     

    What is your Items property of the Gallery?

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 793 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 333 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard