Friday 26 September 2014

Salesforce Custom Label



I have a requirement where I have to display some messages on my visualforce page. I have deal this with apex:pagemessages  if some validation fails and on page with java-script but what will happen if in future I want to change the messages. I don't want to change my code for just some messages.
             To deal with such situation salesforce provides an very useful option "Custom Label". Custom labels are custom text values that can be accessed from Apex classes or Visualforce pages. The values can be translated into any language Salesforce supports. Custom labels enable developers to create multilingual applications by automatically presenting information (for example, help text or error messages) in a user's native language.
                                 
To access Custom Labels go to Setup -> Create -> Custom Labels. This is the best part, Custom Label will be displayed to user depending on their language automatically.  

To refer Custom Label in Visualforce use 
"{$Label.Custom_Label_Name}" 
 Custom Label is one of the Global variable to be used on Visualforce page.

To refer Custom Label in Apex Controller use 
Label .Custom_Label_Name


Note : You can create up to 5,000 custom labels for your organization, and they can be up to 1,000 characters in length.

Where you used your Custom Label ??


Refer: Salesforce

No comments:

Post a Comment