Hello Friends, today we will learn Custom Label in Apex Class and VF Page(Visualforce Page) Salesforce. We use custom labels for translation text. Custom labels are simple text values that are accessed directly in the Apex class and VF page.
For creating custom labels,
Go To Setup —> Create — > Custom Labels.
Click on New Custom Labels. Enter the value for name, value, and description.
We can use custom label names to access custom label values in apex code using System.Label.labelName
and in Visualforce {!$Label.labelName}
Also Check this: custom label in lightning component
Use Custom Label In Apex :
public class CustomLabelTechdicer{
public string customLabelValue{get;set;}
public CustomLabelTechdicer(){
System.debug(System.Label.techdicer);
}
}
On Visualforce Page :
<apex:page>
<apex:pageMessage severity="info"
strength="2"
summary="{!$Label.techdicer}"
/>
</apex:page>
2 comments
I am regular visitor, how are you everybody? This piece of writing posted at this site is in fact fastidious.
Greetings from Colorado! I’m bored to tears at work so I
decided to browse your site on my iphone
during lunch break. I enjoy the knowledge you present here and
can’t wait to take a look when I get home. I’m shocked at how
fast your blog loaded on my mobile .. I’m not even using WIFI, just 3G ..
Anyhow, very good site!