Today's Offer - Salesforce Certification Training - Enroll at Flat 10% Off.

- Salesforce Blogs -

How To Use Custom Labels In Apex Class In Salesforce?

Salesforce has grown to become the most successful customer relationship management solution, which has brought many businesses and their customers together under one roof. It is an integrated platform for CRM which lends power to all the departments in the business, including marketing, sales, commerce, and even the service a combined and single view of every customer. The success of the company can be measured by the fact that more than 150,000 businesses across the world, irrespective of their sizes have shown an unmatched level of growth. The company ever since its conception in 1999 has stayed committed to its time, value and even the equity to improvement in education, equality, and environment. It has helped change the lives of people by the creation of better jobs, lives and even communities.

Custom Labels in Salesforce

Custom labels refer to the custom text values, which are often sought from the apex classes, visual force pages, and even lightning components. For supporting the multilingual feature in an application, custom labels which offer a change or translation in the text values of a user into any other language which are supported by the salesforce are used. It is also helpful in providing the best in class user experience, which offers the application in the native language of the user. Thus, we can say that the custom labels are simple values in the text which are used by the users for translation in any of the salesforces supported languages. They give information in the native language of the user. In the case of Salesforce Visualforce page, it is used in three ways:

  • In Visualforce Page
  • In Apex Class
  • In JavaScript
salesforce Curriculum

 How to use Custom Labels for the content?

  • Firstly, you need to create custom labels for the content.

GotoIISetupIICreateIICustom Labels

How to use Custom Labels for the content?

How to use Custom Labels for the content?

Read: How to Get & Reset Security Token in Salesforce Lightning
  • Secondly, a page is created in visual force and apex class for showing the label as shown in the code.

Visualforce Page Code:

Visualforce Page Code:

Apex Class:

Visualforce Page Code:

Output

Read: Map In salesforce

Visualforce Page Code

Editing of Custom Labels

It has been seen that the custom labels can be created which can be referenced from various Apex classes, Visualforce pages, and even the Lightning components to make the app multilingual.

Editions and User Permissions

  • Creation, Editing and even Deletion of Custom labels are done by customization of the application
  • Creation, or overriding a translation is done by viewing Setup and Configuration and is designated as a translator.

Remember, that editing the attributes of the custom labels which are already installed as part of the managed package is not possible. You can only override the existing translations or even give the new translations for all the languages which are not a part of the package.

salesforce quiz

Editing can be done in the following steps:

  • You need to enter the Custom Label in the Quick Find box and then select the Custom Labels in the Setup.
  • Next, you have to click on the New Custom Label, for creation of the label. If you want to edit, you have to click Edit, which is next to the custom label.
  • Then you need to enter an easily recognizable term for identification of this custom label in the Short Description text box. The description used here is then used in merge fields.
  • Remember that the language of the existing custom label cannot be changed.
  • For the creation of a custom label: In the Name text box, you need to enter the name of label uses. This value is further used in the Apex and the Visualforce pages for referencing the custom label. The names have to contain only alphanumeric characters, have to begin with a letter, shall have no spaces or even the double-underscores and should be unique from all the rest of the labels in the org.
  • The Custom label can be marked as protected by checking the Protected document.
  • In the case of Categories, you have to enter the text for categorizing the label. This is particularly used in the filter criteria when custom label list views are created. Each category is separated by a comma. The total number of characters which are allowed in the text box of Categories is 255.
  • Nearly 1000 characters are used in the Value text box. This value can be translated in any language which is supported by the Salesforce.
  • The changes are finally saved.

Translations of Custom Labels

Translations of the custom labels determine what text will be displayed for a particular value of a label when the default language of the user is the translation language.

User Permissions Needed

  • Creation, Editing and even Deletion of Custom labels are done by customization of the application
  • Creation or overriding a translation can be done by managing translation or even viewing Setup and Configuration and is designated as a translator.

Translation can be done in the following steps:

  • Firstly, you have to enter Custom Labels in the Quick Find box and then pick up the Custom Labels in the Setup.
  • Next, you have to select the name of the custom label to open.
  • Moving further, you are required to Click on New in the Translations related list, for entering a new translation. You may instead Edit next to the language for changing a translation. In case if you hit on Delete, the Salesforce will confirm if you really want to delete, only then it will remove the translation from the custom label. You may then select the language in which you want to translate.
  • Finally, you have to enter the translation text, which ultimately overrides the values which are mentioned in the Value field of the label when the default language of the user is the translation language.
  • Lastly, you have to save the changes which are made.

Creating Custom Labels

Nearly 5000 custom labels can be created in the organization which can be up to 1000 characters long. The custom labels from the managed packages do not count towards this limit. Custom labels can be added to the application depending on the user interface.

Read: Difference between Hubspot and Salesforce CRM
  • In Apex, it uses the System.Label_name syntax.
  • In the case of Visualforce or Lightning components, it uses the $Label global variable.
free salesforce demo

For the creation of the custom labels, you have to enter the Custom Labels in the Quick Find box and then select the Custom Labels. The following syntax can then be used for accessing the labels in the Aura components:

  • $ Label.c.LabeLName for the default namespace
  • $ Label.namespace.LabelName in case there is org has a namespace or accessing a label in a managed package.

Conclusion

Custom Labels let developers create multilingual applications by the automatic presentation of information in the native language of the user. Custom labels are the text values which can be accessed from the Apex classes, Lightning Components, and even the Visualforce pages.


    Janbask Training

    JanBask Training is a leading Global Online Training Provider through Live Sessions. The Live classes provide a blended approach of hands on experience along with theoretical knowledge which is driven by certified professionals.


Trending Courses

AWS

  • AWS & Fundamentals of Linux
  • Amazon Simple Storage Service
  • Elastic Compute Cloud
  • Databases Overview & Amazon Route 53

Upcoming Class

8 days 14 Dec 2019

DevOps

  • Intro to DevOps
  • GIT and Maven
  • Jenkins & Ansible
  • Docker and Cloud Computing

Upcoming Class

9 days 15 Dec 2019

Data Science

  • Data Science Introduction
  • Hadoop and Spark Overview
  • Python & Intro to R Programming
  • Machine Learning

Upcoming Class

9 days 15 Dec 2019

Hadoop

  • Architecture, HDFS & MapReduce
  • Unix Shell & Apache Pig Installation
  • HIVE Installation & User-Defined Functions
  • SQOOP & Hbase Installation

Upcoming Class

-0 day 06 Dec 2019

Salesforce

  • Salesforce Configuration Introduction
  • Security & Automation Process
  • Sales & Service Cloud
  • Apex Programming, SOQL & SOSL

Upcoming Class

14 days 20 Dec 2019

Course for testing

  • Salesforce Configuration Introduction
  • Security & Automation Process
  • Sales & Service Cloud
  • Apex Programming, SOQL & SOSL

Upcoming Class

18 days 24 Dec 2019

QA

  • Introduction and Software Testing
  • Software Test Life Cycle
  • Automation Testing and API Testing
  • Selenium framework development using Testing

Upcoming Class

3 days 09 Dec 2019

Business Analyst

  • BA & Stakeholders Overview
  • BPMN, Requirement Elicitation
  • BA Tools & Design Documents
  • Enterprise Analysis, Agile & Scrum

Upcoming Class

-0 day 06 Dec 2019

SQL Server

  • Introduction & Database Query
  • Programming, Indexes & System Functions
  • SSIS Package Development Procedures
  • SSRS Report Design

Upcoming Class

3 days 09 Dec 2019

Comments

Search Posts

Reset

Receive Latest Materials and Offers on Salesforce Course

Interviews