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 / Referencing a gallery ...
Power Apps
Answered

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

(0) ShareShare
ReportReport
Posted on by 386

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?

 

Categories:
  • EdHansberry Profile Picture
    386 on at

    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. 

     

  • Verified answer
    eka24 Profile Picture
    20,925 on at

    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.

  • EdHansberry Profile Picture
    386 on at

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

  • eka24 Profile Picture
    20,925 on at

    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.

  • EdHansberry Profile Picture
    386 on at

    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!

  • SaiKrishnaGudluru Profile Picture
    499 on at

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

     

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

  • EdHansberry Profile Picture
    386 on at

    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.

  • EdHansberry Profile Picture
    386 on at

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

  • SaiKrishnaGudluru Profile Picture
    499 on at

    @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

  • EdHansberry Profile Picture
    386 on at

    Thanks @eka24 - worked beautifully.

     

    Also thanks @krishnags for the info. Kudos given. I don't think that will work for this scenario as I am using that variable on multiple screens, not just the "next screen" I navigate too. But great to know for most cases.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 337 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 250

#3
Mohsin Ali Profile Picture

Mohsin Ali 225

Last 30 days Overall leaderboard