8

Is there any way to get all custom labels in an org?

Say I have something like this in a controller

public Map<String,String> getCustomLabels() {

    customLabels = [get all labels]

    return customLabels
}

or is there a method to get them through a SOQL query?

8

Custom labels are not accessible via SOQL. You will need to use the Metadata API to complete the query you are looking for.

I would suggest taking 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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.