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

Bug: ThisItem/Gallery.Selected now contains references to controls?

I'm not sure what changed or if I did something to cause it but I'm getting a weird phenomenon.

 

When I'm collecting either ThisItem or Gallery.Selected into a variable or collection I'm suddenly getting extra columns, not present in the datasource, that reference controls in the template and even properties to some extent. 

 

Gallery onSelect()

UpdateContext({_selectedVerzoek:gallVerzoeken.Selected});
ClearCollect(temp, gallVerzoeken.Selected)

image.pngScreenshot of variable content after triggering the onSelectimage.pngScreenshot of Collection content after triggering the onSelect

image.pngContent of the record inside one of the 'control columns'

Needless to say these 'NextArrow3' etc columns are not in my actual datasource attached to the gallery but are names of controls, and I have cut off the columns that ARE in the datasource in the screenshot but they're also still there in the variable/collection. It's just that the embedded controls have become additional columns.

 

When using ThisItem instead of Gallery.Selected the results are slightly different. 

UpdateContext({_selectedVerzoek:ThisItem});
ClearCollect(temp, ThisItem)

image.pngResulting content inside the variable. The mysterious columns don't seem to be records anymore but are still present.

Whereas the Collection now works perfectly fine! No mystery columns...

 

Unless this is something I have caused somehow this feels very much like a bug. I did turn on the Experimental features 'Components' and 'Enhanced group control' recently bug have since turned them off again, saved and restarted the app to test if they were the culprit. 

The controls inside the gallery template mostly just have Select(Parent) in their onSelect(). Nothing fancy there.

The datasource attached to the gallery is an SQL Server table.

 

Anyone have any ideas or clarification? I haven't tried reproducing this in a fresh app yet, but I'm too tired to do it now.

 

Sincerely

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff Mr-Dang-MSFT
PowerApps Staff

Re: Bug: ThisItem/Gallery.Selected now contains references to controls?

Hi @vverb @RandyHayes ,

Gallery.Selected surfaces the columns of the table and all of the controls that are in that selected part of the gallery. This is by design. It is advantageous to get the controls in scenarios where you want to see what was typed into a text input box in the gallery.

 

If you do not want the entire schema, you'll want to do actions from within the gallery and point them to ThisItem.

 

Else, if you want to continue referencing Gallery.Selected from outside the gallery, you can do a look up to what is selected:

LookUp(original_table,id=Gallery.Selected.id)

The only place you will encounter issues is when you use Gallery.Selected in some places and ThisItem in others: the schema will be different. (If you're collecting mismatched schema, PowerApps will take the combined schema anyway). As a best practice, you would stay consistent to your needs.

View solution in original post

6 REPLIES 6
Super User
Super User

Re: Bug: ThisItem/Gallery.Selected now contains references to controls?

@vverb 

I see them too.  They don't seem to be causing an issue at the moment.  I would have expected any EditForms tied to the selected item would have complained because of the extra fields...but they don't from my tests.

 

They do seem to be active live representations of the controls in the gallery for the selected item.

 

I would hope that if it is a slip up that someone "turned on" for the latest build, that they would turn it off before people start using it that way.  If it is intended, it would be nice to hear how it is intented.

 

I could see a ton of uses for it, but I don't dare rely on it at this point until I hear it is intended.

That's what leads to questions on this forum of "my app worked before, and now it doesn't" - oops, looks like someone turned off that slip up in the newest build Smiley Frustrated

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
vverb
Level: Powered On

Re: Bug: ThisItem/Gallery.Selected now contains references to controls?

Good to hear I'm not the only one experiencing this, @RandyHayes !

 

I too was secretly hoping it was a slip up that might indicate they are tinkering with another idea I really support: an self-reference operator like ThisControl similar to how ThisItem works for a record. (https://powerusers.microsoft.com/t5/PowerApps-Ideas/Self-reference-named-operator-for-controls/idc-p...) But maybe that's just wishful thinking.

 

The extra columns in the record are indeed not raising any errors as one would expect and don't break attached forms. But it feels like (might be imagined though) they are causing some 'performance' issues for any attached controls. It feels like they update slower as the record is being modified with the extra columns. Nothing major though. Haven't done any further testing yet.

PowerApps Staff Mr-Dang-MSFT
PowerApps Staff

Re: Bug: ThisItem/Gallery.Selected now contains references to controls?

Hi @vverb @RandyHayes ,

Gallery.Selected surfaces the columns of the table and all of the controls that are in that selected part of the gallery. This is by design. It is advantageous to get the controls in scenarios where you want to see what was typed into a text input box in the gallery.

 

If you do not want the entire schema, you'll want to do actions from within the gallery and point them to ThisItem.

 

Else, if you want to continue referencing Gallery.Selected from outside the gallery, you can do a look up to what is selected:

LookUp(original_table,id=Gallery.Selected.id)

The only place you will encounter issues is when you use Gallery.Selected in some places and ThisItem in others: the schema will be different. (If you're collecting mismatched schema, PowerApps will take the combined schema anyway). As a best practice, you would stay consistent to your needs.

View solution in original post

Super User
Super User

Re: Bug: ThisItem/Gallery.Selected now contains references to controls?

@Mr-Dang-MSFT 

Thanks for the info!  Yes, definitely understand the consistency part.

 

The question though is...is this something new that surfaced? I don't for the life of me recall seeing it before (as in like a few weeks ago.)

And, if new, is it here to stay?

Or am I just so PowerApps googly eyed that I just plan don't recall and it's been there for a long time?

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
PowerApps Staff Mr-Dang-MSFT
PowerApps Staff

Re: Bug: ThisItem/Gallery.Selected now contains references to controls?

@RandyHayes 

For as long as I remember, Gallery.Selected has shown the controls in the gallery as well as the table's columns.

vverb
Level: Powered On

Re: Bug: ThisItem/Gallery.Selected now contains references to controls?

@Mr-Dang-MSFT 

 

Thanks for the explanation. I don't recall ever seeing the controls before but maybe I've only collected ThisItem into a variable before and never done the same with Gallery.Selected. The explanation makes sense and I learned something new about Gallery.Selected.

 

Still a bit weirded out that I got the same effect in my test with just ThisItem, but perhaps I made an oversight and had an UpdateContext to a Gallery.Selected somewhere else in the code.

 

I feel like this type of functionality would benefit from a detailed explanation here: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/controls/control-gallery

The current one is quite lacking. I would also love to know the full details of the functionality (is it all controls? which properties of controls can we expect to access? You mentioned input '.Text' properties, which sounds quite useful, but it's clearly not all properties)

 

PS: a bit of topic but what is your recommended best practice according to this? The default set of generated screens for a 'canvas app generated from a datasource' is an Edit Form screen with Item linked to the Gallery.Selected of the list screen. But I read quite often it is preferable to use a variable to store the record instead. 

 

Thanks in advance

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (7,262)