vlocode-project - v1.40.0-beta-4
    Preparing search index...

    Class SalesforceLabels

    Manages and retrieves Salesforce custom labels with support for localization.

    This class provides functionality to:

    • Retrieve custom labels by their developer names
    • Cache labels for efficient repeated access
    • Support language-specific localized versions of labels
    • Resolve labels with proper namespace handling

    The class maintains an in-memory cache of previously retrieved labels to minimize API calls to Salesforce. When requested labels are not in the cache, it performs a tooling API query to retrieve them along with their localizations.

    // Initialize the class
    const labels = container.get(SalesforceLabels);

    // Get custom labels
    const myLabels = await labels.getCustomLabels(['Error_Message', 'Success_Message'], 'fr');
    console.log(myLabels.Error_Message.value); // Shows French version if available
    Index

    Constructors

    Properties

    connectionProvider: SalesforceConnectionProvider
    labels: Map<string, null | CustomLabel> = ...
    logger: Logger
    nsService: NamespaceService

    Methods

    • Retrieves custom labels by their developer names.

      This method first attempts to resolve the requested labels from the in-memory cache. Any labels not found in the cache are looked up using the lookupLabels method.

      Parameters

      • labels: string[]

        An array of label developer names/keys to retrieve

      • Optionallanguage: string

        Optional language code to retrieve localized versions of the labels

      Returns Promise<
          {
              [k: string]: {
                  fullName: string;
                  language: string;
                  name: string;
                  value: string;
              };
          },
      >

      A promise that resolves to an object mapping label keys to their resolved values. Each resolved value contains the developer name, the label text value, and the language code. If a specific language is requested and available, the returned label will use that localization.