Thursday, March 15, 2018

Salesforce Lightning : Dynamic Custom labels in lightning components

Custom labels are used in Salesforce to present the information which are not available in database not part of data records. For eg: the page headings, button labels, help text etc... The custom labels gives an option for developers to present multilingual information  based the end used language. The mail application areas of custom labels are the Visualforce pages & Lightning components.

Custom labels in lightning components 

The custom labels are included in Lightning components as :
  • {!$Label.c.labelName} for the default namespace
  • {!$Label.namespace.labelName} to access a label in a managed package
Else we can use the javascript method :
  • $A.get("$Label.c.labelName")
  • $A.get("$Label.namespace.labelName")

Dynamic Custom labels in lightning components

In some situations  we have to dynamically include the Custom labels on the go.  ie we can only be able to determine the label name on the run time.  The below component will help to get the dynanic label values on the run time

No comments:

Post a Comment