function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
santhoshreddy vanchasanthoshreddy vancha 

what is the main use of custom lable please give some example s?

NagendraNagendra (Salesforce Developers) 
Ho Santosh Reddy,

Custom Labels. 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. Custom labels are custom text values that can be accessed from Apex classes, Visualforce pages, or Lighting components.

Create and Edit Custom Labels:

1.From Setup, enter Custom Labels in the Quick Find box, then select Custom Labels.
2.To create a label, click New Custom Label. To edit a label, click Edit next to the custom label.
3.In the Short Description text box, enter an easily recognizable term to identify this custom label. This description is used in merge fields.
4.If you’re creating a custom label: In the Name text box, enter the name the label uses. This value is used in Apex and Visualforce pages to reference the custom label. Names must contain only alphanumeric characters, start with a letter, contain no spaces or double underscores, and be unique from all other labels in your org.
5.To mark the custom label as protected, check Protected Component.
6.For Categories, enter text to categorize the label. This field can be used in filter criteria when creating custom label list views. Separate each category with a comma. The total number of characters allowed in the Categories text box is 255.
7.In the Value text box, enter text up to 1,000 characters. This value can be translated into any language that Salesforce supports.
8.Click Save.

Please find the sample example below. The advantage of using custom label is that label will be displayed to user depending on their language automatically. We need to specify translation for label using translation workbench.

After creating custom label we can use following code to use custom label in apex code.1 <!-- VISUALFORCE PAGE.
<!-- VISUALFORCE PAGE -->
<apex:page controller="CustomLabelApexDemoController">
   <apex:form >
     <apex:pageblock >
       Value stored in custom label is: <b>{!customLabelValue}</b>
     </apex:pageblock>
   </apex:form>
</apex:page>
// Controller class
public class CustomLabelApexDemoController {
    public string customLabelValue{get;set;}
    public CustomLabelApexDemoController(){
        customLabelValue = System.Label.DemoLabel;
    }
}
For further reference please check  Hope it helps you!

Please mark this as solved if my reply was helpful so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Thanks,
Nagendra

 
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for custom label
1) https://help.salesforce.com/articleView?id=cl_about.htm&type=0

Custom labels enable developers to create multilingual applications (http://amitsalesforce.blogspot.com/2015/01/translation-workbench-salesforce.html)by automatically presenting information (for example, help text or error messages) in a user’s native language. Custom labels are custom text values that can be accessed from Apex classes, Visualforce pages, or Lighting components. The values can be translated into any language Salesforce supports

You can create up to 5,000 custom labels for your organization, and they can be up to 1,000 characters in length. Custom labels from managed packages don’t count toward this limit

Create and Edit Custom Labels (https://help.salesforce.com/articleView?id=cl_edit.htm&type=0&language=en_US)

To access custom labels, Go To Setup — Create — Custom Labels. Click on New Custom Labels.Enter value for name, value and description. We can use custom label name to access custom label value in apex code using System.Label.labelName

Sample code to use Custom label in apex class
String test = Label.<custom label name>;

for example:

String test = Label.ok;

Please check below post how to use same in VF page
http://www.sfdcpoint.com/salesforce/custom-label-in-apex-code-salesforce/

http://www.infallibletechie.com/2012/11/how-to-use-custom-labels-in-visualforce.html
 
<apex:page standardController="Account" extensions="sample">
<h1>Example for Custom labels</h1>
<apex:outputLabel value="{!$Label.Sample}"/>
</apex:page>

Let us know if this will help you

 
Arti JibalwadArti Jibalwad
Example:

Create Custom Label:
1]search name "Custom Label" in searchbox
2]Create New Custom Label
3]Write the Name of the Label.    {ex: Welcome_Message }
4]write the word you want to see on the VF page in the description box.   {ex:Hello..Wel-Come to salesforce}
5]Save the custom Label

VisualForce page:

<apex:page>
<apex:pageBlockSection>
<apex:outputText>
           <h1>{!$Label.Welcome_Message}</h1>
</apex:outputText>
</apex:pageBlockSection>
</apex:page>

Output:
Hello..Wel-Come to salesforce

Here,You are simply displaying your convinient Word except those VF page/Salesforce Hard coded literals, just to make the understanding better.

Hope this Helps!
 
Jesse Schabert 3Jesse Schabert 3
The original quetion was "what is the main use of custom lable please give some examples?" but what has been provided so far are only definitions of what they are (copied from the salesforce help document) and then instructions on how to create them. nothing about HOW they are used with examples. Nothing was asked about how to create them ,but yet there are very detailed instructions on how to do so. Can anyone please answer the question asked ?