# getLabelForElementNames Not Working

**URL:** <https://forum.servoy.com/t/getlabelforelementnames-not-working/18124>\
**Category:** Classic Servoy\
**Created:** [August 15, 2014, 11:30am UTC](https://forum.servoy.com/t/getlabelforelementnames-not-working/18124 "2014-08-15T11:30:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mccourt.cordingley](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@mccourt.cordingley](https://forum.servoy.com/u/mccourt.cordingley)\
**Post date:** [August 15, 2014, 11:30am UTC](https://forum.servoy.com/t/getlabelforelementnames-not-working/18124/1 "2014-08-15T11:30:32Z")

</div>

Hi

When calling

````auto
elements.cd_id.getLabelForElementNames()
``` on fields for which labels have had the labelFor property set correctly
I am getting an empty Array returned

I am running build 7.4.1 build 2028

Is anyone else seeing this issue

Example

````

application.output(elements.cd\_id.getLabelForElementNames())

```auto

returns [].

Labelfor property is set correctly
[attachment=0]ScrrenShot.png[/attachment]

![ScrrenShot.png|534x171](upload://gP7ylNInxjfsWNIvj0cp9bqvXGU.png)
```

---

<div class="post-metadata">

**Author:** ![maria.kyselova](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@maria.kyselova](https://forum.servoy.com/u/maria.kyselova)\
**Post date:** [August 18, 2014, 1:28am UTC](https://forum.servoy.com/t/getlabelforelementnames-not-working/18124/2 "2014-08-18T01:28:16Z")

</div>

Mine works fine in the same Servoy version.

I recall a while ago we could not access a field in the code through elements.field because at design time the field was on the parent rather than child form. Do you use form inheritance?

---

<div class="post-metadata">

**Author:** ![mccourt.cordingley](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@mccourt.cordingley](https://forum.servoy.com/u/mccourt.cordingley)\
**Post date:** [August 18, 2014, 9:03am UTC](https://forum.servoy.com/t/getlabelforelementnames-not-working/18124/3 "2014-08-18T09:03:42Z")

</div>

Hi Yes

We do on this form but it is redundant now.  
I will check that out thanks for the tip.

---

<div class="post-metadata">

**Author:** ![Mccourt.cordingley1372837951](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@Mccourt.cordingley1372837951](https://forum.servoy.com/u/Mccourt.cordingley1372837951)\
**Post date:** [August 27, 2014, 9:11am UTC](https://forum.servoy.com/t/getlabelforelementnames-not-working/18124/4 "2014-08-27T09:11:58Z")

</div>

Hi

I have now removed the inheritance on the form in question and the outcome is still the same.

```auto
application.output(elements.cd_id.getLabelForElementNames())

```

returns the same, an empty array

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [August 28, 2014, 11:25am UTC](https://forum.servoy.com/t/getlabelforelementnames-not-working/18124/5 "2014-08-28T11:25:07Z")

</div>

Could it be that your are maybe in a table view? At runtime, you don’t have access to label\_for labels in table view, because they are no longer there. They are used to format the table header, but don’t actually exist at runtime.

---

<div class="post-metadata">

**Author:** ![Mccourt.cordingley1372837951](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@Mccourt.cordingley1372837951](https://forum.servoy.com/u/Mccourt.cordingley1372837951)\
**Post date:** [August 28, 2014, 2:29pm UTC](https://forum.servoy.com/t/getlabelforelementnames-not-working/18124/6 "2014-08-28T14:29:33Z")

</div>

Hi

Yes I am in table view.  
That’s a bit rubbish, do you know a work around?

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [August 28, 2014, 2:36pm UTC](https://forum.servoy.com/t/getlabelforelementnames-not-working/18124/7 "2014-08-28T14:36:10Z")

</div>

You can use the solutionModel. In the blueprint, these labels do exist.

---

<div class="post-metadata">

**Author:** ![Mccourt.cordingley1372837951](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@Mccourt.cordingley1372837951](https://forum.servoy.com/u/Mccourt.cordingley1372837951)\
**Post date:** [September 1, 2014, 10:30am UTC](https://forum.servoy.com/t/getlabelforelementnames-not-working/18124/8 "2014-09-01T10:30:19Z")

</div>

Hi Patrick

What would be the code for that as I cannot see it in any of the solution model options.

Is it

```auto
var _elm = solutionModel.getForm(form).getComponent(elm).getLabelForElementNames

```

That is giving me warnings

---

<div class="post-metadata">

**Author:** ![Mccourt.cordingley1372837951](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@Mccourt.cordingley1372837951](https://forum.servoy.com/u/Mccourt.cordingley1372837951)\
**Post date:** [October 27, 2014, 10:50am UTC](https://forum.servoy.com/t/getlabelforelementnames-not-working/18124/9 "2014-10-27T10:50:55Z")

</div>

Any help with this would be appreciated.

---

<div class="post-metadata">

**Author:** ![deezzub](https://avatars.discourse-cdn.com/v4/letter/d/dec6dc/32.png) [@deezzub](https://forum.servoy.com/u/deezzub)\
**Post date:** [October 27, 2014, 12:45pm UTC](https://forum.servoy.com/t/getlabelforelementnames-not-working/18124/10 "2014-10-27T12:45:08Z")

</div>

You can get a label with:

```auto
solutionModel.getForm( form ).getLabel( labelName )

```
