Sunday, April 14, 2013

Salesforce Custom Label

Custom Label maybe not so popular among Salesforce administrator compare to other feature, such as: workflow, formula field and so on, even less popular compare to Custom Setting. Custom Label also enable admins or developers to show data/value in multi-language.

Custom Label may be more popular for developers to store a variable, but Custom Label actually also available for system administrator to be used in formula field, workflow rule, and validation rule. For a formula field that refer to custom label, value of the formula field will be depend on value from custom label referred, when display in page layout or report, it will be displayed based on language selected in user detail.

To create Custom Label, click Setup | Create | Custom Labels. You only can add translation language based on languages supported in your Translation Workbench.

Once created, you can find Custom Label in Global Variable start with $Label

Once added in formula field or other places, it will show with format $Label.Label_Name

Custom Label enable developers to create multilingual applications by automatically presenting information in a user's native language from Apex class or Visualforce page.

For Apex class, it would be just a simple as: String strMyLabel = Label.Hello;

Note: if you want to set Custom Label in multi-language, you need to enable Translation Workbench. To enable Translation Workbench from Setup | Translation Workbench | Translation Settings, then add and activate languages that you need.

Reference: Custom Labels

No comments:

Post a Comment

Page-level ad