cancel
Showing results for 
Search instead for 
Did you mean: 

Parent & Me - please add reference to the control itself.

We can reference control to a parent (Like Parent.Width, .Height, .Fill, etc.). For the controls however we have to reference it by it's name. So when I have a control name 'Label1' I can reference it bij Label1.Width, .Height, . Color, .Fill, etc.

 

It should be a great idea to add a global reference to the control itself. Me comes in mind as a good name for this parameter. So Me.Width, .Height, .Fill, etc.

 

This parameter would make it faster to copy formula's from control to control or add a formula to multiple selected controls. An example:

 

Say I have ten controls (Control1,2,3,4,5,...) and I want them to be at the left off my screen. I can then select them all and just do  the following formula on the X parameter: 

Parent.Width - Me.Width

 

Current I must adjust the formula for each control like:

Parent.Width - Control1.Width // for the first control
Parent.Width - Control2.Width // for the second control
Parent.Width - Control3.Width // for the third control
// and so on

This is time consuming because I have to copy/paste/adjust for each individual control.

So I would make a major time reduction to be able to do all ten controls in the same time.

 

Status: Completed

This is provided with the self fx shown below.

 

Adding @FilipK from the Power Apps team in case there are any follow-up questions, since I don't see it in the formula reference doc here yet.

Comments
New Member

This shows how immature PowerApps is. Not having Me. or ThisItem. etc.

Microsoft Access has had this Self OO approach since the 1990's.

Come on guys, you can do better that this.

Advocate IV

My preference is "ThisControl" more so than "This" or "Me" or "Self."  I think a bit more wording will make it easier for newbies to differentiate between "ThisItem" for the data record reference versus "ThisControl" for the properties of the control itself.

 

Someone pointed out that JS uses "This."  I would have to agree that that is a strong argument for using that notation instead....as even with my limited JS skills, I still look at PowerApps formulas like JS scripts.  But if I get to pick, "ThisControl."  But at this point, I'll take ANYTHING as anyway to self-reference will be a HUGE time saver.

Advocate II

I was shocked this essential functionality isn't implemented yet.
This has to come ASAP!
@Audrie-MSFT any updates on this Review? I would save tons of hours in my current project...

Resident Rockstar

@Audrie-MSFT  I noticed that the Self comment is now available in PowerApps. Could you close this thread?

 

Thanks.

Advocate II
Advocate II

@KroonOfficeSol,

I found Self  in my Preview-Environment but can't figure out how to use it.

From my understanding it's a Text/Constant with a value of "_self", not a function or a pointer to the current object.

 

ControlPropertyFormulaResult
ButtonWidthSelf + 100100
  Self.Heightsyntax error
  Self()syntax error
 TextSelf_self

 

Do you have an idea on how to use it?

Regards, TxH

Resident Rockstar
Self.Height

 

This is the right way to use it. What is the input on the Height property?

Advocate II

@TxHI'm not quite sure what you are trying to achieve but here is an example of using "Self".

For example you want to set the height of your text-input-field to half of its width then you set the property 'Height' to:
Self.Width / 2

Advocate II
Advocate II

@leo41 @KroonOfficeSol ,

 

Button1.Width = 200

Button1.Height = Self.Width

(should be 200, but throws error "Invalid use of '.'")

 

I tested in an Preview Environment and the app has all experimental features enabled.

 

Advocate II

@TxHI can't reproduce your error

ezgif.com-video-to-gif.gif


Advocate II
Advocate II

@leo41,

seems to be a tenant/environment version problem.

I created a new Preview environment and it works now as expected.

 

Thanks, TxH