cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate V
Advocate V

Referencing a gallery item on a different screen - doesn't always work

I have this code on a button in a gallery:

 

Navigate(
    scrBrowseQuotes,
    Transition.None
)

 

Then on the scrBrowseQuotes screen, I make reference to the selected item several times, for example, this is in the header for the screen:

 

"Quotes for " & galItemSelection.Selected.ItemNumberVersion & " " & galItemSelection.Selected.ItemDescription1 & " (" & galItemSelection.Selected.DisplayType & ")"

 

It always works in development, but in production it will occasionally be empty, returning just "Quotes for ()".

And the other controls on the screen are empty or blank.

I know the gallery item was selected because the button in the gallery wouldn't have transitioned the user to the new screen otherwise. The only fix for the user is to hit BACK then select the button by the item in the gallery again, which always works the 2nd time.

 

This isn't a browser issue - I've seen it fail in the exact same browser in production vs development, where it never fails.

 

I can redo the screens to work around this by setting a global variable in the gallery button to carry the item's name, then populate that way vs using gallery.Selected.blahblah, but didn't want to if that isn't ideal. Plus, I'll have to create several variables to capture all of the data I need.

 

Any ideas on why this happens?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Referencing a gallery item on a different screen - doesn't always work

Change formula in the Gallery by putting this code in in icon or button inside the Gallery:

Set(galItemSelect,ThisItem);Navigate( scrBrowseQuotes, Transition.None )


Then change the other code to:

 

"Quotes for " & galItemSelect.Selected.ItemNumberVersion & " " & galItemSelect.Selected.ItemDescription1 & " (" & galItemSelect.Selected.DisplayType & ")"

 

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

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.

View solution in original post

10 REPLIES 10
Highlighted
Advocate V
Advocate V

Re: Referencing a gallery item on a different screen - doesn't always work

We also see this on Forms that are using the selected item in the gallery:

EdHansberry_0-1596562570076.png

and that never goes away. But there are no running ants across the top of the screen.

The data source is a SQL server via on-prem gateways (cluster of 3).

I never see this when developing the app. Only when it is published. 

 

Highlighted
Super User III
Super User III

Re: Referencing a gallery item on a different screen - doesn't always work

Change formula in the Gallery by putting this code in in icon or button inside the Gallery:

Set(galItemSelect,ThisItem);Navigate( scrBrowseQuotes, Transition.None )


Then change the other code to:

 

"Quotes for " & galItemSelect.Selected.ItemNumberVersion & " " & galItemSelect.Selected.ItemDescription1 & " (" & galItemSelect.Selected.DisplayType & ")"

 

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

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.

View solution in original post

Highlighted
Advocate V
Advocate V

Re: Referencing a gallery item on a different screen - doesn't always work

Thanks @eka24 - I'll give that a shot. Is this a bit of a known issue? 

Highlighted
Super User III
Super User III

Re: Referencing a gallery item on a different screen - doesn't always work

With the approach you took, when moving from one screen to another, a variable will be needed.

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

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.

Highlighted
Advocate V
Advocate V

Re: Referencing a gallery item on a different screen - doesn't always work

Ok, thanks. I've not seen that in the documentation (I could have missed it) and it does work sometimes. But I'll consider this "best practice" and update my app accordingly. I'll come back and mark this as solved in the next day or so as I test this with users to ensure it works ok. 

 

Again, thanks!

Highlighted
Responsive Resident
Responsive Resident

Re: Referencing a gallery item on a different screen - doesn't always work

@EdHansberry you can try Navigate function, which can hold Context Variables.

 

Navigate(Screen Name, ScreenTransition.None,{ ID: 1 })

Highlighted
Advocate V
Advocate V

Re: Referencing a gallery item on a different screen - doesn't always work

Now I get it. I knew referencing other objects as "variables" from other screens was not a good idea. Making a label with the word "Green" in it for example then setting objects to that color using that label on other screens.

It didn't click with me I was doing the same with the gallery. Then I looked at the performance recommendations:

EdHansberry_0-1596644418156.png

 

I have 40-45 objects referencing this gallery that way. Fixing now with a global variable set to ThisItem.

Highlighted
Advocate V
Advocate V

Re: Referencing a gallery item on a different screen - doesn't always work

@krishnags - are you saying it will transfer the value of a context variable from one screen to another?

Highlighted
Responsive Resident
Responsive Resident

Re: Referencing a gallery item on a different screen - doesn't always work

@EdHansberry yes, this is a recent (probably 3-4 months back) feature for Navigate function. Refer https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-navigate for full documentation

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,224)