Showing posts with label Custom Label. Show all posts
Showing posts with label Custom Label. Show all posts

Thursday, May 12, 2022

How to Get Custom Label Using SOQL

Hello All

Today we are going to discuss How to Get Custom Label Using SOQL

Custom labels are custom text values that can be accessed from Apex classes, Visualforce pages, or Lightning components. The values can be translated into any language Salesforce supports.

the Custom Labels in org write the following SOQL Query.
Note: Use Tooling API to Query

1st way

Select Id, Name FROM CustomLabel WHERE Value = '<your Value>'


Check the screenshot for more information about the result.










2 nd way

Select Id,Name,Masterlabel,Value,IsProtected,Category,Language,ManageableState FROM ExternalString WHERE Name='TestLabel'

Output:

 

Sunday, July 19, 2020

how to use custom label in Lightning Web Components – LWC

Hello All,

Today we will disscus, how to use custom label into Lighting web componet (LWC).
Sample steps,we will follow below steps for that

1.Create custom labels
To create custom labels, from Setup, enter Custom Labels in the Quick Find box, then select Custom Labels. Here are the custom labels created. we will see how to use the lightning web components

2.Use Custom Labels in LWC
import labelName from '@salesforce/label/labelReference';

labelName—A name that refers to the label.
labelReference—The name of the label in your org in the format namespace.labelName

Sample Code:- 

// labelExample.js

import { LightningElement } from 'lwc';

// Import the URL for the static resource named 'salesforceLogo'
import SALESFORCE_LOGO from '@salesforce/resourceUrl/salesforceLogo';

// Import custom labels
import greeting from '@salesforce/label/c.greeting';
import salesforceLogoDescription from '@salesforce/label/c.salesforceLogoDescription';

export default class LabelExample extends LightningElement {
    // Expose the static resource URL to use in the template.
    logoUrl = SALESFORCE_LOGO;

    // Expose the labels to use in the template.
    label = {
        greeting,
        salesforceLogoDescription,
    };
}
<!-- labelExample.html -->

<template>
    <c-page-header header="Using static resources and custom labels" description="This sample shows how to reference external items like static resources and custom labels"></c-page-header>

    <c-card>
        <img src={logoUrl} alt={label.salesforceLogoDescription} width=100><br>
        <br>
        {label.greeting}
    </c-card>
</template>

For more detail :-Please visit salesforce site:-Access Labels