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 / Gallery Item.Selected ...
Power Apps
Unanswered

Gallery Item.Selected vs Variable issue

(0) ShareShare
ReportReport
Posted on by 10

Hi there Power App community!

 

I've recently implemented a change on a clients canvas app where the issue they were having is that the refresh button above a gallery, when selected, would set the gallery to another events gallery list altogether.

 Setup:
Screen 1 - Event Gallery for Today

Screen 2 - Invitee gallery based on screen 1's selected event.

 

I fixed this by applying a variable to the event gallery Item.Selected. Then, no matter how many times you click refresh or tick an invitee, it does not refresh the gallery and set it to the first event on screen 1's gallery.

 

My problem comes in now, that when multiple users use the canvas app and want to see the latest updates of the invitee list, they select the refresh button and nothing changes. This is because the variable I was setting to prevent the gallery from pulling from refreshing to the first event gallery Item.Selected is remaining static and will not allow for screen 2's gallery to update (even though I'm telling it to refresh the datasource and reset screen 2's gallery).


My question is this, is there a way to reset the variable of the Item.Selected from screen 1 without having to set it to the first item in screen 1's gallery? Is there a way, without having to refresh the items in screen 2's gallery without having to change the Item that was selected from screen 2 i.e. get that reference the same.

Categories:
I have the same question (0)
  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @barryfrancis 

     

    Set OnSelect property of Gallery to (From screen 1)

     

    Set(ItemSelected, Screen1Gallery.Selected); Refresh('Screen2DataSource');

     

     

    Make sure Screen2 Gallery uses the variable item selected.

     

    This will make sure the 2nd screen gets the selected item from the screen and refresh screen2.

     


    Thanks,
    Stalin - Learn To Illuminate

  • Verified answer
    v-jefferni Profile Picture
    on at

    Hi @barryfrancis ,

     

    Since you have two separate screens, in each screen includes a Gallery, I assume you will need to refresh the second Gallery with the button without leaving screen2, please consider below steps:

    1. Set another variable to store the selected event's item ID:

     

    Set(var1, Gallery1.Selected); //OnSelect of Events Gallery
    Set(var2, var1.ID)

     

     

    2. OnSelect of the refresh button:

     

    Set(var2, Blank());
    Set(var2, var1.ID)

     

     

    3. Edit Items of the Invitee Gallery, replace the var1 (Item.Selected) with below codes:

     

    LookUp(Events, ID = var2)

     

     

    So each time a user refresh the Gallery via clicking the button, Gallery2 items will firstly be cleaned up (because ID = blank) then filled by the actual items.

     

    Hope this helps.

     

    Best regards,

    Community Support Team _ Jeffer Ni
    If this post helps, then please consider Accept it as the solution to help the other members find it.

  • Barry Francis NTT Profile Picture
    10 on at

    Hi Stalin,

     

    If I use Gallery.Selected, when I do a reset of the Gallery2 on screen2, the ItemSelected variable is lost and replaced with the first gallery item at the top of screen 1. This will set the items on gallery 2 on screen2 to a whole new event...

  • Barry Francis NTT Profile Picture
    10 on at

    Hi Jeffer Ni,

     

    Thank for you the suggestion. I'm getting the following error on the refresh part of the solution provided:

    Invalid number of arguments: received 1, expected 2

    barryfrancis_0-1635934776281.png

    On following the suggestion, when I select the item from Gallery1 on screen1, I am setting the following variables:

    Set(ItemSelected, Gallery1.Selected);
    Set(ItemSelectedSecond,ItemSelected.'Campaign ID');

    barryfrancis_1-1635934838255.png

     

    Then, on the second gallery, I've set the following as it will need to apply a filter via a search box sitting above gallery 2 as well:
    Sort(
    Filter(Invitees,
    Event.'Campaign ID'=ItemSelectedSecond,
    TextSearchBox1.Text in 'Invitee Name'.'Full Name'
    ),
    'Invitee Name'.Surname
    )

     

    This is still working as required so far. Its the third step, when setting the refresh button that causing the error at the moment. Any ideas?

  • Barry Francis NTT Profile Picture
    10 on at

    Hi Jeffer Ni,

     

    I got my syntax mixed up, I set it incorrectly:

    barryfrancis_0-1635935841174.png

     

    I updated it correctly, ran a test and the second persons screen, when they clicked on the refresh button, had the updated invitee record details come through perfectly.

     

    Thank you for the solution!

     

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard