1

How can we count number of custom labels available in Apex class in Salesforce? Do we have any query for this ?

oookkk
  • 61
  • 2
  • 6

4 Answers4

2

Metadata API with the following solution.

  1. Login to Workbench.

  2. Go to 'Migration | Retrieve'

  3. Upload package.xml below
  4. Unzip output and count number of labels by <fullname>

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>*</members>
        <name>CustomLabel</name>
    </types>
    <version>37.0</version>
</Package>

To do that in Apex, you may get more details in the shared link. By deploying to your org, there's a demo page that does so.

enter image description here enter image description here

-end-

EugeneO
  • 41
  • 5
1

You can use Metadata API. Take a look at Andrew Fawcett's Apex Wrapper Salesforce Metadata API.

With the API you can query the CustomLabels metadata type to get the information you are looking for.

Sagar Pareek
  • 1,215
  • 8
  • 17
1

Easiest way is probably Workbench>Info>Metadata Types & Components>CustomLabel and check the number

Workbench

Robin De Bondt
  • 3,761
  • 1
  • 22
  • 35
0

I don't think its possible for now. You can vote this Idea.

Custom Labels count

Tushar Sharma
  • 29,515
  • 7
  • 36
  • 60