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
Resolver II

Definitely need *This* (pun intended)

Saying that this issue is completed because you can name the control is like saying you never did any object oriented programming.

Kudo Commander
Kudo Commander

@Audrie-MSFT 

+1 on the @HansHeintz  comment.

Advocate IV

Yippie!  It looks like the cavalry is coming. I.e. the "Self" keyword is now available in the preview channel.

 

See this thread for more info.

 

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Parent-amp-Me-please-add-reference-to-the-contr... 

Power Apps
Status changed to: 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

Advocate II

@GregLi Thank you!!!

Kudo Kingpin

LOL, this idea was one big emotional roller coaster - just like Power Apps. 🙂  Too bad I don't develop in Power Apps anymore. 😞 😞 😞 😞 😞 😞

Kudo Kingpin

Dropdown control's value

DataCardValue29.Selected.Value

 returns the text "Yes"

 

Attempt to color same dropdown control based on its value using the Self operator

If(Self.Selected.Value = "Yes",Green, Red)

 returns the error "Name isn't recognized..." on Value

 

Is this supposed to work but just doesn't, or is this still not going to actually work for this?

 

Textbox works as expected

In a plain text box, this works fine checking the current text value of the textbox using the Self operator

If(Self.Text = "test", Red, Green)

 

Advocate II

@PhilD Have you confirmed what the .value of your drop-down is/are?  e.g. create a label and set its text to the drop-down's selected value.

Kudo Kingpin

Yes, the first bit of formula is from that label.

 

I will close down all my browser windows and try again later this morning. there have been several occasions lately where things don't work (such as the undo/redo buttons, data card with snapping to zero, and even some other formulas) and then when I clear my cache and restart it works for a while again.