cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Refer to current object

Is there a way to reference the current object using a 'this' reference or equivalent?  Meaning I have 6 toggles that when OnCheck or OnUnCheck they add/remove their respective tooltip text to a collection. So the code is the same except for having to reference each toggle object by name.  I was hoping there is a fast way to select all the toggles and do something like this in the OnCheck:

Collect( colToggleChoices,  this.Tooltip )

where "this" refers to the current object.  This way I don't have to select each toggle one at the time to edit the code.

 

Thanks for any info.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Refer to current object

Hi @mattbrice ,

Currently, The "this" operator is not supported within PowerApps currently. If you want to select all the toggles and use "this" to reference current object (Toggle control), I afraid that there is no way to achieve your needs in PowerApps.

If you would like this feature to be added in PowerApps, please submit an idea to PowerApps Ideas Forum:

https://powerusers.microsoft.com/t5/PowerApps-Ideas/idb-p/PowerAppsIdeas

 

As an alternative solution, I think Gallery control and ThisItem operator could achieve your needs. I have made a test on my side, please take a try with the following workaround:5.JPG

 

6.JPG

 

7.JPG

Add a Gallery control (Gallery1) within the screen of your app, set the Items property of the Gallery to following:

Table(
      {Name:"Toggle1", Tooltip:"First Toggle"},
      {Name:"Toggle2", Tooltip:"Second Toggle"},
      {Name:"Toggle3", Tooltip:"Third Toggle"},
      {Name:"Toggle4", Tooltip:"Forth Toggle"},
      {Name:"Toggle5", Tooltip:"Fifth Toggle"},
      {Name:"Toggle6", Tooltip:"Sixth Toggle"}
)

Within the Gallery, add a Label control and a Toggle control (Toggle1). Set the text property of the Label control to following:

ThisItem.Name

Set the Tooltip property of the Toggle control (Toggle1) to following:

ThisItem.Tooltip

Add one button outside the Gallery -- "OnCheck" button (on my side, it is called "Collect"). Set the OnSelect property of the "OnCheck" button to following:

ForAll(
Filter(Gallery1.AllItems, Toggle1.Value = true),
Collect(colToggleChoices, Toggle1.Tooltip)
)

After you checked the corresponding Toggle controls within the Gallery, click the "OnCheck" button, then the corresponding checked Toggle controls' Tooltip value would be saved into the colToggleChoices collection.

Note: You could also consider take a try to add a another button -- "UnCheck", to achieve your UnCheck logic as above.

 

Please check the attached GIF screenshot for more details:

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Highlighted
Community Support
Community Support

Re: Refer to current object

Hi @mattbrice ,

Currently, The "this" operator is not supported within PowerApps currently. If you want to select all the toggles and use "this" to reference current object (Toggle control), I afraid that there is no way to achieve your needs in PowerApps.

If you would like this feature to be added in PowerApps, please submit an idea to PowerApps Ideas Forum:

https://powerusers.microsoft.com/t5/PowerApps-Ideas/idb-p/PowerAppsIdeas

 

As an alternative solution, I think Gallery control and ThisItem operator could achieve your needs. I have made a test on my side, please take a try with the following workaround:5.JPG

 

6.JPG

 

7.JPG

Add a Gallery control (Gallery1) within the screen of your app, set the Items property of the Gallery to following:

Table(
      {Name:"Toggle1", Tooltip:"First Toggle"},
      {Name:"Toggle2", Tooltip:"Second Toggle"},
      {Name:"Toggle3", Tooltip:"Third Toggle"},
      {Name:"Toggle4", Tooltip:"Forth Toggle"},
      {Name:"Toggle5", Tooltip:"Fifth Toggle"},
      {Name:"Toggle6", Tooltip:"Sixth Toggle"}
)

Within the Gallery, add a Label control and a Toggle control (Toggle1). Set the text property of the Label control to following:

ThisItem.Name

Set the Tooltip property of the Toggle control (Toggle1) to following:

ThisItem.Tooltip

Add one button outside the Gallery -- "OnCheck" button (on my side, it is called "Collect"). Set the OnSelect property of the "OnCheck" button to following:

ForAll(
Filter(Gallery1.AllItems, Toggle1.Value = true),
Collect(colToggleChoices, Toggle1.Tooltip)
)

After you checked the corresponding Toggle controls within the Gallery, click the "OnCheck" button, then the corresponding checked Toggle controls' Tooltip value would be saved into the colToggleChoices collection.

Note: You could also consider take a try to add a another button -- "UnCheck", to achieve your UnCheck logic as above.

 

Please check the attached GIF screenshot for more details:

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Advocate II
Advocate II

Re: Refer to current object

Going to just reply here with the links to some of the many idea posts that already exist for this. Please please upvote them so the PowerApps team considers implementing it.
https://powerusers.microsoft.com/t5/PowerApps-Ideas/Ability-to-reference-items-in-a-control-using-qu...

https://powerusers.microsoft.com/t5/PowerApps-Ideas/Self-reference-named-operator-for-controls/idc-p...

 

Highlighted
Frequent Visitor

Re: Refer to current object

Thanks for the response as I am somewhat new to Powerapps and hadn't considered using a gallery which in my scenario might just work.  Of course unfortunately the problem with a gallery is i can't free form place the toggle on the screen, but i might work around this.  Thanks.

Highlighted
Community Support
Community Support

Re: Refer to current object

Hi @mattbrice ,

Based on the needs that you mentioned, I think the Gallery control may be the only available solution to achieve your needs.

The "this" operator is not supported within PowerApps currently, if you would lhike this feature to be added in PowerApps, please submit an idea to PowerApps Ideas Forum:

https://powerusers.microsoft.com/t5/PowerApps-Ideas/idb-p/PowerAppsIdeas

 

Please consider take a try with the alternative solution I mentioned above, then check if it could achieve your needs. If you have solved your problem, please go ahead to click "Accept as Solution" to identify this thread has been solved.

Please also check and see if the following video would help in your scenario:

https://www.youtube.com/watch?v=PBrtWL1RFDk

 

Best regards, 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Advocate IV
Advocate IV

Re: Refer to current object

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... 

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,906)