cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
seraph787
Level: Powered On

Set Gallery.Default based on Global Variable

Hi I have an app that uses different galleries that filter a SharePoint list on different screens with different Filters().  I'd like to set it so that when the user selects from the Gallery on Screen1, they can go to Screen2 or Screen3 and see the same item selected by default in those galleries.

I was thinking to try something like having the gallery onselect for these galleries set a global variable (varID) to the SP Item's ID.  Then setting the defaults of other Galleries to {ID: varID} or Lookup(spListCollection,ID = varID) - but neither of these seems to do the trick. 

I could do Gallery1.Selected but that only works if both Galleries reference the data in the same way.  One Gallery may reference it with AddColumns() to facilitate certain functions, another gallery may reference it with Filters().  I can't really get around having to AddColumns and Filters, so I think I need some way to look up based on a global variable.

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff Mr-Dang-MSFT
PowerApps Staff

Re: Set Gallery.Default based on Global Variable

@seraph787 ,

It sounds like you want to show a default selected item for the gallery elsewhere. 

Lookup(spListCollection,ID = varID)

The formula above should work if the Gallery's items is spListCollection or some filter on it.

 

Can you run Reset(galleryname) and see if that helps bring it to the record you want?

 

@RandyHayes who is also good with galleries.

4 REPLIES 4
powerdiver
Level 8

Re: Set Gallery.Default based on Global Variable

My initial response would have been:

 

you don't even really need a global variable as you can use the Selected.idcolumnname on the original gallery .. and that works out for me.. now where I was wrong on my initial way to answer:

LookUp(Gallery2_1.AllItems,id=Gallery2.Selected.id)

is that somehow, the 'Gallery2.AllItems' is not having the right behaviour somehow when I (even) select the same row in my first gallery (Gallery2) than in my second(Gallery2_1).. so I ended up doing as follow:

 

LookUp(listGroupValue,id=Gallery2.Selected.id)

 

this works fine, just change the 'listGroupValue' for the same statement you have in your 'Items' property

 

** performance wise, I'd reccomend working with a collection as a source for Items and the lookup statement in the default property, just to make sure it's all cached in and you don't fetch data to the server every time you change the selected item

 

PowerApps Staff Mr-Dang-MSFT
PowerApps Staff

Re: Set Gallery.Default based on Global Variable

@seraph787 ,

It sounds like you want to show a default selected item for the gallery elsewhere. 

Lookup(spListCollection,ID = varID)

The formula above should work if the Gallery's items is spListCollection or some filter on it.

 

Can you run Reset(galleryname) and see if that helps bring it to the record you want?

 

@RandyHayes who is also good with galleries.

Super User
Super User

Re: Set Gallery.Default based on Global Variable

@seraph787 

Let us know if you're still having the issues or if you have worked it out.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
seraph787
Level: Powered On

Re: Set Gallery.Default based on Global Variable

Thank you @powerdiver and @Mr-Dang-MSFT .  All of these work great.  Specifically the Reset() helped make it a bit more pronounced (rather than having to scroll up/down to find what's now selected).

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 4 members 4,243 guests
Please welcome our newest community members: