getLabelForElementNames Not Working

Hi

When calling

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())


returns [].

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

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

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?

Hi Yes

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

Hi

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

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

returns the same, an empty array

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.

Hi

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

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

Hi Patrick

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

Is it

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

That is giving me warnings

Any help with this would be appreciated.

You can get a label with:

solutionModel.getForm( form ).getLabel( labelName )