cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
arisima
Advocate I
Advocate I

get control name in OnSelect

Hi,
Is it possible to get Control name string value in events like OnSelect?

So if there is a control named "Button1", in "OnSelect" I would write something like:
Set(ThisButtonName, Me.Name);

For debugging purposes, I am trying to log which button was pressed,
and I do not want to hard-code button names.


Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User III
Super User III

@arisima 
There is no way for a button or any other control to reference 'Self' to get this information.  You must hardcode it.

 

Suggest you go vote for the Idea right now!  Microsoft is reviewing this feature request and if it gets enough votes it will be introduced into PowerApps.

 

Link To Idea Page:

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Ability-to-reference-items-in-a-control-using-q...

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up." 

View solution in original post

2 REPLIES 2
mdevaney
Super User III
Super User III

@arisima 
There is no way for a button or any other control to reference 'Self' to get this information.  You must hardcode it.

 

Suggest you go vote for the Idea right now!  Microsoft is reviewing this feature request and if it gets enough votes it will be introduced into PowerApps.

 

Link To Idea Page:

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Ability-to-reference-items-in-a-control-using-q...

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up." 

View solution in original post

KrishnaV
Super User III
Super User III

Hi @arisima ,

 

As @mdevaney said, unfortunately, there is no way in powerapps to implement this behavior I can see that you are a traditional .Net developer. However, since you said that it is for debugging purpose what you can do is:
onScreen visible: updatecontext{varBtnSelected:""} and bind/show this variable to a label. Now on each and every button update the context of the variable with the button name as updatecontext{varBtnSelected:"Add Item Button clicked "} or updatecontext{varBtnSelected:"Edit Item button clicked"}.

 

So that will automatically update the label value and will give you a better picture for your debugging. Hope this helps.

 

Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

Regards,
Krishna

 


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (41,774)