cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
EdHansberry
Kudo Collector
Kudo Collector

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

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
EdHansberry
Kudo Collector
Kudo Collector

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. 

 

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.

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

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.

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!

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

 

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

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.

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

@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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,048)