cancel
Showing results for 
Search instead for 
Did you mean: 

Self reference named operator for controls

Could we please have an operator like ThisControl which works in a similar way to ThisItem/Parent but for controls?

This is usefu if you want to reference one of the control's other properties when setting the value for another property (i.e. make the border the same colour as the text, where the text is a formula).

For example

TextBox1.BorderColor = ThisControl.Color

This way, when you copy the control, the reference is still ok.

Thank you.

Status: Completed

I'm pleased to announce that there is a new Self operator that references the current control, very similar to the Parent operator.  Available in version 3.20051.

2020-05-20_20h59_51.gif

Comments
krushton
Regular Visitor

Related topic with suggested use case that is not addressed with current functionality:

 

https://powerusers.microsoft.com/t5/PowerApps-Ideas/Parent-amp-Me-please-add-reference-to-the-contro...

agusriyadi
Regular Visitor

This is simply one of the basic tenet in programming : Don't Repeat Yourself (DRY). Having the keyword ThisControl (or Me or Self or This or whatever agreed) does not just save time to copy paste, it also saves time to read a code.

It is a must have feature. Please implement this feature. 

Anonymous
Not applicable

Just to add to the array of comments, this feature e.g. ThisContol.Default, ThisControl.DisplayMode would be seriously useful and seems like a rather basic idea that has been missed out of the powerapps development.

 

Thanks,

 

Benjamin

MrsNaniPenny
Advocate I

I agree wholeheartedly with the thread of this request!

 

Please implement a dynamic reference to the control itself. I like the idea of ThisContol.

 

Can someone from @microsoft please respond whether they agree with this and if so, when we can expect it? Is this the right forum for the request?

originalltd
Advocate II

The request to this is not complete. It's a feature request marked as complete, but is not complete.

 

We need a reference back to an object to identify itself.

seraph787
Advocate III

I agree with @originalltd .

 

This is definitely not complete.

DeeTronSEAM
Advocate V

Please @Audrie-MSFT , can you return this to an active status?  This functionality does not yet exist and its need/usefulness remains quite high even with Components now being available.

 

Also, put me down as preferring "ThisControl" more than "Self"  >   "Me"    > "This."

It's a few extra characters to type, but it's unequivocal in what "it" is that the code is referring to....and it aligns with (yet, clarifies a difference with) "ThisItem" being used for data objects (i.e. records in a collection or table).

PhilD
Kudo Kingpin

This is definitely not "Complete" as the status suggests. Can anyone from the dev team at least provide some update on this basic functionality please.

Gregory
Regular Visitor

I concur that there needs to be a ThisControl reference as soon as possible, as it will speed up development of complex apps quite a bit. This should not be considered completed.

 

I have noticed however that if you modify a control's properties by referring to another one of its properties (like making ButtonA.RadiusBottomLeft = ButtonA.Height/2), when you make a copy of the control the copy references its own properties and not the original's. So if I copy ButtonA, the resulting ButtonB's RadiusBottomLeft value is ButtonB.Height/2. It's not optimal but at least it's better than referencing the original properties.

 

Not sure when this was implemented, as I'm very new with PowerApps.

eagleBasti
Regular Visitor

Status: Not completed. 

 

It is neither possible to address a control type inside a property of an component nor possible to reference the property by it's own. 

 

As previous developers here already announced, it is not possible to get a 'this pointer'!

This is necessary due to the reasons described in previous comments, that an professional handling of multiple components is almost hard to achieve. 

 

And there is also an Exploid:

Enter property record into component:

{ self : 《component_name》}

And with ctr+s

The process will end up in an exception, following a session end after crash. 

This can be misused for a denial of service attack. 

 

So, please set the issue back to in progress and fix it asap. 

Best your customer