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 Apps
Unanswered

Gallery Selection

(0) ShareShare
ReportReport
Posted on by 57
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:
I have the same question (0)
  • Suggested answer
    MS.Ragavendar Profile Picture
    4,975 Super User 2025 Season 2 on at
     
    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.
  • mrichards1371 Profile Picture
    57 on at
    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. 
  • Pstork1 Profile Picture
    68,697 Most Valuable Professional on at
    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
    57 on at
    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
    68,697 Most Valuable Professional on at
    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
    57 on at
    @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.
     
     
     
     
  • Verified answer
    Pstork1 Profile Picture
    68,697 Most Valuable Professional on at
    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
     
  • Suggested answer
    Power Platform 1919 Profile Picture
    1,890 on at
    Hi @mrichards1371,
    you can please try this 
    Coalesce(my_record,Gallery1.Selected)  // Here my_record should be replaced with your variable.
    I think this works in your case.
     

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 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard