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 / Get field property fro...
Power Apps
Answered

Get field property from Gallery on App start

(1) ShareShare
ReportReport
Posted on by 71

Hi All, 

 

I have an app with a simple screen that has a gallery and a form for details.   When the app starts, I need to get the Title property from the selected item in the gallery (the first row).  I know this can easily be done through the OnSelect function of the gallery, but this is not triggered on App start.  I've tried to get it on the Screen.Onvisible function, but that's not working.  

 

Hope this makes sense, and thanks for any help!

 

Cheers!

 

Categories:
I have the same question (0)
  • Verified answer
    AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    Instead of getting it from the gallery what you need is this:
    Get the datasource of the gallery (Including filter if applicable)
    and then wrap it in First()
    e.g. i have a datasource on my gallery and i need the first row. my gallery's datasource is Filter(Contacts, 'Created By'.domainname = User().Email) so i would do First(Filter(Contacts, 'Created By'.domainname = User().Email))

  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    Let me know if you need me to help you adapt this to your use case/onstart criteria. 

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

    @TeeroyLyon 

    Information from controls is global in PowerApps.  The Title of the selected row of a gallery can be obtained from any place.  yourGallery.Selected.Title is what you would need.

    Keep in mind that using the data from any control in the app in OnStart may yield incorrect data as the controls might not have been completely initialized and most certainly, no user has selected anything yet.  

    This is another reason to avoid variables in your app and reference the controls instead as the variable will be a snapshot of the value at a time and will never change until you change it again in your formulas.

     

    I hope this is helpful for you.

  • TeeroyLyon Profile Picture
    71 on at

    Thanks @AJ_Z ...this is pretty much what I was looking for and works great!

     

    Cheers,

    Troy

  • TeeroyLyon Profile Picture
    71 on at

    Thanks for this Randy...I was looking more for what @AJ_Z recommended.  But maybe this will help someone else searching.  And yes, the main issue is control initialization.

     

    Cheers,

    Troy

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

    @TeeroyLyon 

    Hopefully it will be avoided as using the First(Filter combination is very poor for performance.

    The point however is, your Gallery already has the information in it and has gone through the cost of going to the datasource already, you can reference that then in the app as needed.  Otherwise, you are making more trips to the datasource which is costly on performance.

    So in your case, if you wanted the first item of that Gallery, then First(yourGallery.AllItems) will be that record.  And no costly trip to the datasource again.

  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    @TeeroyLyon I am very happy to help 🙂

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

#2
11manish Profile Picture

11manish 134 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 101 Super User 2026 Season 2

Last 30 days Overall leaderboard