Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

How do I get a form to populate with the first item in a gallery when a filter is applied to the gallery?

(0) ShareShare
ReportReport
Posted on by 821 Super User 2025 Season 1

I have a gallery that updates a form with the gallery item selected. Now, when I am on the screen and use a filter on the gallery the form blanks. I would like it to auto select the first gallery item. 

 

I'm not sure of this is related but if I navigate off the screen and then come back the last gallery item I viewed is still in the form instead of resetting. In this case I would also like to select the first item in the gallery.

 

One thing I did notice. If I choose the most recent record from and of the filters the form will populate. It won't do it for any older records(gallery items) unless I click on the item in the gallery.

 

Hope this is not confusing

Categories:
  • futr_vision Profile Picture
    821 Super User 2025 Season 1 on at
    Re: How do I get a form to populate with the first item in a gallery when a filter is applied to the gallery?

    @Ethan_R 

    I failed to read the continuation of your answer before responding. So let me see if I understand how to implement this.

    1. When the screen loads I should set a context variable to First(Gallery1.AllItems)
    2. When I select another record from the gallery I need to set the form to the selected item?
    3. When a filter is applied, I need to reset the variable and set it to First(Gallery1.AllItems)?

    Something like this?

  • futr_vision Profile Picture
    821 Super User 2025 Season 1 on at
    Re: How do I get a form to populate with the first item in a gallery when a filter is applied to the gallery?

    Hmm. Interesting. It does select the first item in the gallery. Problem is when I select any other item in the gallery the form only shows the first item. I need to be able to select gallery items and at the same time default to the first item is none are selected. Sounds like I need to build out some logic

  • Ethan_009 Profile Picture
    4,838 Super User 2025 Season 1 on at
    Re: How do I get a form to populate with the first item in a gallery when a filter is applied to the gallery?

    Hi @futr_vision ,

     

    You can create a variable and use it on the Form.

    //For getting 1st record use
    
    First(Gallery1.AllItems)

     

    You can use this to your variable or Form. 

    Note: You need to define you variable every time but direct reference can become unstable as if context is gone from other screen, your data may go blank or value may change based on filters. So, try keeping that constant with a variable else you select 1 record and then it changes the record and you will update other record.

     

    Hope this helps 

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,547 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,928 Most Valuable Professional

Leaderboard