3

Is it possible to retrieve custom labels dynamically in javascript?

Works well:

var labelTest = '{!JSENCODE($Label.MY_LABEL)}';

I need to do something like this:

var text = 'MY_LABEL';
var labelTest = '{!JSENCODE($Label.'+text+')}';

It is not working. I am getting the error:

Syntax error. Found '$Label.'

How to achieve this?

0

Try below format where labelName is the name of the label

{!JSENCODE($Label[labelName])}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.