Monday 17 August 2015

What is custom label in Salesforce?

Custom labels are custom text values which stores 1000 characters long data in it.

When to use custom label?
1. Custom labels are used whenever large amount of data needs to be displayed in a visualforce page or in force.com sites.

2. Custom labels are custom text values that can be accessed from apex codes and visualforce pages.

3. Custom labels are also used if we need to display multiple languages in same page we need to go to custom labels instead of hardcoding.

eg:- If i am having a force.com sites which is having multiple languages in the site. Then i will first language language translation apex class and then add custom labels based on languages. If i select my language as English in force.com site it will displays text as English. If i select my language as French then it will displays french related text in the force.com site.

4. We can create 5000 custom labels for an organization.

Syntax:-

<apex:outputLabel value="{!$Label.CustomLabelName}"/>


Sample Code:

<apex:page standardController="Account" extensions="sample">
<h1>Example for Custom labels</h1>
<apex:outputLabel value="{!$Label.Sample}"/>
</apex:page>




No comments:

Post a Comment