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 Platform Community / Forums / Power Apps / Retaining Gallery Sele...
Power Apps
Suggested Answer

Retaining Gallery Selections after navigating to a new form

(1) ShareShare
ReportReport
Posted on by 45
I have three galleries on a screen that are linked to related SharePoint Lists.
- The user selects a row in Gallery1 and Gallery2 is filtered based on that result.
- Once a row is selected in Gallery2, Gallery3 is filtered on that result to display related items.
 
There is a button that takes the user to a newform to add a record to the Sharepoint List related to Gallery3. The selections made in Galleries 1 and 2 on the previous screen are saved to variables and used to prepopulate the newform.
 
My question is once the new record is submitted and I am returned to the main screen, my galleries are reset. Is there a way to keep the items selected in the galleries visible after the creation of the new record?
 
Thankyou.
I have the same question (0)
  • Suggested answer
    jpespena Profile Picture
    335 on at
    Hi,
     
    You can pass the variables back to the previous screen by adding context variables in the Navigate function like:
     
    Navigate(Screen1, ScreenTransition.Fade, { locSelectedGallery1: varSelectedGallery1, locSelectedGallery2: varSelectedGallery2 })
    Assuming that varSelectedGallery1 and varSelectedGallery2 are the variables passed to the second screen.
     
     
    Then, change the Default property of Gallery1 to locSelectedGallery1 and Gallery2 to locSelectedGallery2.
     
     
  • ronaldwalcott Profile Picture
    3,847 Super User 2025 Season 2 on at
    Also remember you need an operation to clear the variables used as the Default property in the galleries.
  • MZ-18110459-0 Profile Picture
    45 on at
    Thank you.
     
    This is what I currently have in place. My questions are highlighted in orange below
     
    MainScreen:
    Gallery1
    • OnSelect property, Set(varSelectedGallery1,ThisItem);
    • Items property, 'List1'
    • Default property, Defaults('List1')
    Gallery2
    • OnSelect property, Set(varSelectedGallery2,ThisItem);
    • Items property, Filter('List2', 'ID-From-List2'=Gallery1.Selected.ID)
    • Default property, {} (Is this what you mean?)
    Gallery3
    • OnSelect property, Set(varSelectedGallery3,ThisItem);
    • Items property, Filter('List3','ID-From-List3'=Gallery2.Selected.ID)
    • Default property, {} (Is this what you mean?)
    User presses "New Item in List3" button
    ResetForm(NewForm);NewForm(NewForm);Navigate(scrnNewForm)
    NewForm:
    Note, these are dependent Combo Boxes
    • Combo Box 1
      • Default property, Blank()
      • DefaultSelectedItems, LookUp(Choices([@'List3'].'FieldRelatedToList1'), Value = varSelectedGallery1.Title)
      • Items property, Choices([@'List3'].'FieldRelatedToList1')
      • OnSelect property,
        • If the user decides to reselect in this form we want to ignore the variables. I'm resetting to blank here, so I suspect this is the issue when I return to the gallery. Is there a better way to do this?
          • Reset(DataCardValueCombobox2);
          • Reset(DataCardValueCombobox3),
          • Set(varSelectedGallery1,Blank()); 
          • Set(varSelectedGallery2,Blank());
    • Combo Box 2
      • Default property, Blank()
      • DefaultSelectedItems, LookUp(Choices([@'List3'].'FieldRelatedToList2'), Value = varSelectedGallery2.Title)
      • Items property, Filter('List2', 'FieldRelatedtoList1' = DataCardValueCombobox1.Selected.Id)
      • OnChange property, Reset(DataCardValueCombobox3);
    • Combo Box 3
      • Default property, Blank()
      • DefaultSelectedItems, LookUp(Choices([@'List3'].'FieldRelatedToList3'), Value = LookUp('List4',ID = varSelectedGallery2.IDField,Title))
      • Items property, Filter('List4', ID = DataCardValueEvComboBox2.Selected.Id,Title)
    Once everything is selected, a patch is run and the user is Navigated back to the main screen and I was going to try the suggestion made by jpespena. Do I need to remove the set to blank on the Combo Box 1?
     
    Thank you!
  • jpespena Profile Picture
    335 on at
    Hi,
     
    Default properties should be:
     
    Gallery1 - varSelectedGallery1
    Gallery2 - varSelectedGallery2
    Gallery3 - Blank()
     
    And yes, you should remove the Set() functions on the combo box that sets the variables to blank to keep the values when you go back to the previous screen.
  • MZ-18110459-0 Profile Picture
    45 on at
    Thank you
  • jpespena Profile Picture
    335 on at
    No problem!
     

    If my post helped resolve your issue, please click Accept as Solution—this helps others find it more easily and marks the item as closed. If you found this or my previous reply helpful, a Like would also be appreciated!

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard