Skip to main content
Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Suggested answer

Gallery Selection

(0) ShareShare
ReportReport
Posted on by 48
Hello, 
 
I was watching a YouTube video where it said when using a Gallery and Form, that it's best practice to not set the Form Item to Gallery.Selected. Instead, you should set a variable on the Gallery OnSelect, then reference that variable in the Form Item. 
 
For Example: 
Gallery On Select : Set(varForm, ThisItem) 
 
Form Item (varForm). 
 
When I put this in my app and open the screen that has the Gallery and Form on it, it does not show any data until I actually click on one of the Gallery items. How do I set it so it always shows the data of the most recently created Gallery when opening the screen? 
Categories:
  • Pstork1 Profile Picture
    67,079 Most Valuable Professional on at
    Gallery Selection
    Where you set the first record if you aren't using a deep link, change the 'New Customer Request' datasource to 
    use the Filter you use in the Gallery.  That way the first record won't have Completed as the status.

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
  • mrichards1371 Profile Picture
    48 on at
    Gallery Selection
    @Pstork1 Thanks for the suggestion. Now that I have set the varRecord to take the first record in 'New Customer Request' if varID is blank, it is now opening and displaying data on the Form.
     
     
     
    I've run into another problem though. On this Gallery, I am filtering out any records that have the status of Complete or Sales Rejected. I show these records on different screens in the app. 
     
    Now my app will default to the Form showing a "Complete" record, even though I am filtering out this status in my Gallery. I understand it is doing this because this Complete record is the First in 'New Customer Request' data source, but I'm not sure how to incorporate this filter in my OnStart formula that I showed that the top.
     
     
     
     
  • Pstork1 Profile Picture
    67,079 Most Valuable Professional on at
    Gallery Selection
    That should work, but only if you start the app using a Deep Link with the parameter included.  If you just start the App normally then varID will be blank and the lookup won't work so varRecord will be empty.  You need to add something in the App onStart that checks whether the parameter is blank or not.  If it is then set varRecord to some known value or Use First() to set it to the first record in the data source.

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
  • mrichards1371 Profile Picture
    48 on at
    Gallery Selection
    Hello @Pstork1
     
    I am using this variable in my App OnStart section so I can deep link the SharePoint ID. Is there a way to deep link without using this variable? Deep linking is what got me into this mess, I'd much rather be using gallery.selected! 
     
  • Pstork1 Profile Picture
    67,079 Most Valuable Professional on at
    Gallery Selection
    I'm curious, what reason did they give for not wanting to use Gallery.Selected?  The only one I can come up with is that the Gallery selects the first record when the app loads by default. If you want your form to be blank until someone clicks on something then using a variable would do it. Since you specifically state that you don't want that behavior then I wouldn't use a variable.  So to be honest, I don't consider that a best practice. Its extra code for no particular reason and will result in the behavior that you describe.  As I said, wanting that behavior is the only reason I can see for using a variable.

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
  • mrichards1371 Profile Picture
    48 on at
    Gallery Selection
    Thank you for your reply @MS.Ragavendar. I may have worded my initial post wrong. 
     
    This is what I have on my Gallery OnSelect:
     
     
    This is what I have on my Form Item:
     
     
    When I open my app, it defaults the Form to "Getting Data" until I actually click on one of the Gallery items. It's strange because it looks like one of the Gallery items is selected when opening the app. 
     
    This issue does not happen when I have Form Item to Gallery.Selected. 
  • Suggested answer
    MS.Ragavendar Profile Picture
    2,752 on at
    Gallery Selection
     
    In the gallery, I added one Icon (Icon.Edit).
     
    On Select Property of the Icon 
     
    Set(varselectedItem,ThisItem);
    EditForm(Form1);
     
    // In the same screen itself i have used the form control, if you are using the separate screen u need to use the navigate function as well.
     
     
     
    Edit Form Control - Add the respective fields accordingly.
     
     
    DataSource - ur sharepoint list  (in my case its novice)
     
     
    Item Property - varselectedItem 
     
    // This is variable i am using it 
     
     
     
    Save button 
     
     
    If you have further queries 
    🏷️ Please tag me @MS.Ragavendar if you still have any queries related to the solution or issue persists.
     
    If issue resolved
     Please click Accept as solution if my post helped you solve your issue and help others who will face the similar issue in future.
     
    ❤️ Please consider giving it a Like, If the approach was useful in other ways.

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2