0

I am trying to use custom label during call of a lightning component in Visualforce Page. but its giving me blank value. can anyone please help me how i can do this,

CODE:

$Lightning.createComponent("c:AccSearchComponent",
    { 
      // Set Lightning Component Attributes Property before creating Lightning Component In Visualforce page 
        textColor : "Red",
        ObjectToQuery : "how to use CUSTOM LABEL HERE !!"                
    },
   "LcDisplayId",
    function(component) {
        // create component Callback, Lightning Component has been Created,
        // Now you can set more lightning Component attributes here,
        // and do more cool stuff here

    });
 });
3
  • have you tried invoking createComponent after you actually have a custom label value? are you unable to fetch the custom label value? what is the problem exactly?
    – glls
    Commented Jan 20, 2019 at 19:54
  • Hi, I am using ObjectToQuery : $Label.c.objName, but its not working. I think i am not using correct syntax.
    – Sharma_raj
    Commented Jan 21, 2019 at 5:02
  • 1
    @RAT__ That syntax is incorrect because you are in Visualforce, not in Lightning, and need to use the Visualforce syntax.
    – David Reed
    Commented Jan 21, 2019 at 14:53

1 Answer 1

2

It's not much different from any other Custom Label access in Visualforce. You'll need to use the $Label global in a Visualforce expression ({! }) to obtain the Custom Label value. Since you're merging the value into JavaScript, you must also wrap the value in the JSENCODE() function to escape any special characters that might be present in the label value.

The Lightning Out context doesn't change this approach; the Lightning JavaScript isn't executed until it reaches the client, after the Visualforce markup is rendered on the server.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .