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

Gallery.Selected is not working as it's supposed to be

Hi I am trying to display data in a textinput control based on which checkbox is selected in a gallery.  But it seems that the statement: 'Gallery.Selected.CollectionField1' is giving unintended results.  For example in the gallery if I had 2 items A & B.  If I check A first, then I check B second.  Then I uncheck B, and hit the modify button to go back to the previous screen, it should show item 'A' data.  But it shows item 'B', or whatever was checked OR unchecked last.  I tried the Refresh(Gallery1.Selected) or Refresh(Gallery1.AllItems) in the Modify button 'OnSelect' property but that didnt work.   Would appreciate the help. Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Gallery.Selected is not working as it's supposed to be

Hi @mahakala_ 

 

Yes, Gallery.Selected points to the record where the mouse was clicked last. If you wish to get the record where the checkbox value is checked, then you might have to perform some calculation over it. The selection works in a way where if any item in a specific item of a gallery is clicked, this changes the gallery selected item.
 
If you are looking to get the item where the checkbox is checked, you can use the expression: 
LookUp(Gallery3.AllItems, Checkbox3.Value = true).Title
 
Here, Gallery3 is the name of Gallery and Checkbox3 is the name of checkbox inside. This is returning the Title column out of it. 
Note: This will just pick one record, the first record that satisfies this criteria. 
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
7 REPLIES 7
Super User
Super User

Re: Gallery.Selected is not working as it's supposed to be

Hi @mahakala_ 

 

Can you try to update few configs as:
 
Modify Button OnSelect -> Set(ResetCheckbox,true);Set(ResetCheckbox,false)
 
Checkbox Control -> Reset -> ResetCheckbox
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
mahakala_
Level: Powered On

Re: Gallery.Selected is not working as it's supposed to be

Hi @yashag2255 ,

 

Thanks for reply.  I tried the code but that did not work.  It still see's the last thing I do to the checkbox (whether it's checking it or unchecking it) as the one that is selected.  

 

Also I put 'ResetCheckbox'; in the Reset property of the checkbox, but it is giving me an error because I already have a contextvariable in there.  For some reason it does not like it and giving error 'Expected operator. We expect an operator such as +, *, or & at this point in the formula.  Operators join two operands together.  This error occurs if you put two functions (operands) together with no operator between them -- for example, Len("mytext")Len("mytext").  

 

I have ContextvariableA; ResetCheckbox; in there.  I commented out ContextvariableA to try the method you gave me, but as I said up top, it still doesn't work.  

Super User
Super User

Re: Gallery.Selected is not working as it's supposed to be

Hi @mahakala_ 

 

Reset is a boolean type field, which only expects its value to be true or false, if you write two expressions in it, this will not be a supported value, can you update your expression to:
ContextvariableA && ResetCheckbox
 
I am assuming that ContextvariableA is of type boolean.
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
mahakala_
Level: Powered On

Re: Gallery.Selected is not working as it's supposed to be

ok I guess thats why if I commented out contextvariableA, the error goes away.  But as I said earlier, Set(ResetCheckbox,true);Set(ResetCheckbox,false); did not work.  It is still seeing the last thing I did to the checkbox as the Gallery.selected.collectionfield1.  Any other suggestions?

mahakala_
Level: Powered On

Re: Gallery.Selected is not working as it's supposed to be

HI @yashag2255 ,

 

I noticed that Gallery.Selected does not look at what record is checked in the gallery, rather it looks at what was selected by the mouse click.  See picture below.  I last unchecked checkbox A, so it leaves a box around the checkbox.  So it sees that as the Gallery.Selected.  Anyway where it looks at the checked box instead of the last thing the mouse touched?

 

 

image.png

Super User
Super User

Re: Gallery.Selected is not working as it's supposed to be

Hi @mahakala_ 

 

Yes, Gallery.Selected points to the record where the mouse was clicked last. If you wish to get the record where the checkbox value is checked, then you might have to perform some calculation over it. The selection works in a way where if any item in a specific item of a gallery is clicked, this changes the gallery selected item.
 
If you are looking to get the item where the checkbox is checked, you can use the expression: 
LookUp(Gallery3.AllItems, Checkbox3.Value = true).Title
 
Here, Gallery3 is the name of Gallery and Checkbox3 is the name of checkbox inside. This is returning the Title column out of it. 
Note: This will just pick one record, the first record that satisfies this criteria. 
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
mahakala_
Level: Powered On

Re: Gallery.Selected is not working as it's supposed to be

Hi @yashag2255 ,

 

Yes that worked!  LookUp(Gallery3.AllItems, Checkbox3.Value = true).Title is a powerful expression.  I'll be sure to use this more in the future.  Tried all day trying to fixed this.  Thank you so much for your help. 

 

 

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

Top Community Contributors for September  2019

Top Community Contributors for September 2019 🎉🎉

Let's thank our top community contributors

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

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

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 279 members 4,298 guests
Please welcome our newest community members: