cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MisterMagoo
Helper II
Helper II

Get the name of a control (self.Name does not exist)

Hi folks. Am I wrong, or it is still currently not possible to get the name of a control? 


I'd like to have a way to retrieve the name of the current checkbox, because the name of the current checkbox is my key to retrieve a value in a collection of "key - value" couples. 

 

Unfortunately "Self.Name" does not exist...

 

THX
Bye!
A.-

6 REPLIES 6
cds
Impactful Individual
Impactful Individual

the self.value solution was not to get the name of an element.

 

how is the name of a control your key value pair?

@cds , I have 3 groups of checkboxes, each group associated to 8 different countries (countries are the same in the 3 groups).

To Country #1 in group #1 I need to associate one email address. 

To Country #1 in group #2 I need to associate another email address.

To Country #2 in group #1 ... and so on. I have 3 x 8 = 24 different email addresses.

 

I have a collection clcEmailAddresses composed by {code - email address} couples.

I decided to use the chechbox name to retrieve the corresponding email from the collection:  I cannot use the TEXT of the control, because it simply contains the Country full name.  Therefore, if I am not wrong, the only way to uniquely identify the checkbox is the name. 

All these checkboxes have a "chkCC_G" code, where CC = country codce (8 values) and G = group (1 to 3). Eg. chkUS_1, chkFR_2...

As soon as the checkbox is checked, the corresponding email address is concatenated in a specific editbox control. 

Do you think there is another way to get a unique ID of the current checkbox, so that I can use it as a key in my Collection? 

cds
Impactful Individual
Impactful Individual

if you want get the checkbox name, why not just hardcode it in since the names stay the same..?

v-siky-msft
Community Support
Community Support

Hi @MisterMagoo ,

 

In my understanding, there is no need to reference the Checkbox Name as the index.

If you want to get the selected email addresses concatenated, why not try to concatenated it directly based on checkbox value?

For example, use the following code to display concatenated email addresses you select.

Concatenate(

If(Checkbox1.Value,"Test1@microsoft.com"&Char(10)),

If(Checkbox2.Value,"Test2@microsoft.com"&Char(10)),

If(Checkbox3.Value,"Test3@microsoft.com"&Char(10)),

....

)

 

Another workaround is to collect all selected email addresses into a  collection, for example:

Checkbox1: 

OnCheck: Collect(colEmail,"Test1@microsoft.com")

OnUncheck: Remove(colEmail,LookUp(colEmail,Value="Test1@microsoft.com"))

 

Checkbox2: 

OnCheck: Collect(colEmail,"Test2@microsoft.com")

OnUncheck: Remove(colEmail,LookUp(colEmail,Value="Test2@microsoft.com"))

 

and so on.

Then use Concat(colEmail,Value,Char(10)) code to display concatenated email addresses.

Snipaste_2020-07-29_09-59-25.png

 

Hope this helps.

Sik

Hi @v-siky-msft , thanks for the answer! 

 

I prefer to keep all email addresses in a collection, because these email addresses may vary, and if I have them all in a single Collection, it's way easier to change them (rather than editing each one inside each checkbox). 

Now I concatenate the email addresses as you can see below: if the checkbox is checked, then I look for the "key" value in the EmailAddresses collection, and the concatenated result is the "Text" property of the EditBox control.

It is working fine, althoug the code below is quite ugly 🙂

 

MisterMagoo_0-1596024053332.png

(I know, it is stupid to use another "Concatenate" to append the ";" to the email address! it is a left-over of a previous version, I am going to change it soon)

Why am I still trying to get the "checkbox" name? 
Because I'd like to show the associated email address as a tooltip, when hovering on the checkbox.
If I am able to retrieve the name of the checkbox, I can simply enter the same function in all "tooltip" properties of the checkboxes, after selecting them all. 

Something like this:

 

"First(Search(EmailAddresses,ThisControl.Name,"Type")).Email"

 

 

But since I am not able to do it, I'd need to customize this function for each checkbox, hard-coding the checkbox name (which I am using as the key to retrieve the email address). And I'd like to avoid this boring activity...

Does it make more sense now? 

Bye!
A.-

 

Hi @MisterMagoo ,

 

OK, I got it. But I'm afraid there is no OOB ways to reference the control name, which isn't a output property for now. And I can't find any alternative workaround as there is no more extra property to store the index. 

Maybe you can consider creating a component like checkbox, which you can create some extra properties.

Sik

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,519)