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 / How to retain selectio...
Power Apps
Answered

How to retain selection in Gallery + Form on DB refresh

(0) ShareShare
ReportReport
Posted on by 523

I am using CDS & have a screen with a Gallery & Form. The selected gallery item populates the form & the form can be edited.

My problem is however, that the gallery selection gets lost when I execute Refresh(Database).

Is there a way either to retain the gallery selection when a form is submitted, or to re-select the previous item after a form has been edited (and the database refreshed)?

Thanks!

Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,925 on at

    Try these steps:
    1. OnVisible of the screen put: 

    UpdateContext({GallerySelected:!GallerySelected})
     
    2. Insert another Gallery say Gallery4 and on its items put:
    Form1.LastSubmit ....(Form1 to your actual form name)
     
    3.Finally on the Item of the Form1 put:

    If(GallerySelected,Gallery4.Selected,If(!GallerySelected,Gallery2.Selected))

    Change Gallery2 to your existing Gallery connected to the form

     

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • Verified answer
    Power_Robert Profile Picture
    117 on at

    Hi @Medoomi,

     

    What you can do for the OnSelect() of your Refresh Button is something like this:

    Set(varSelectedItemID, Gallery1.Selected.Id);
    Refresh(Database)

     

    Now on the Default() of you Gallery you can do something like this:

    LookUp(Database, Id = varSelectedItemID)

     

    Hope this helps.

  • Medoomi Profile Picture
    523 on at

    @eka24 

    Thanks so much for your answer. I'm trying to understand the process. Am I correct thinking that Gallery4 would become a kind of "holding place" for the previously submitted form... So in practice, once the form was submitted, while Gallery2 might become de-selected, the form selection would remain?

  • eka24 Profile Picture
    20,925 on at

    The idea is to be able to choose from either Gallery2  which holds the existing record and Gallery 4 which holds the latest submitted item. 

    You have a choice of selection between the two at any point in time.

     

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 541

#2
WarrenBelz Profile Picture

WarrenBelz 434 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 289

Last 30 days Overall leaderboard