3

I am trying to retrieve the list of custom labels created into a list table format or in excel. All the solutions I have viewed so far is by mentioning the name of the label to retrieve the description. I want to be able to retrieve the list dynamically without mentioning the name of the label.

6

You can use the Metadata API to pull down all the labels at once by using the wildcard character.

Here is an example package.xml for accomplishing this:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
  <types>
    <members>*</members>
    <name>CustomLabels</name>
  </types>
<version>34.0</version>
</Package>
3
  • Thanks Phil, this worked! But is there a way we can schedule it somewhere to run every day or something? I want the latest custom labels to be retrieved in regular intervals. Jul 20 '15 at 4:44
  • No problem. If you have a server available you could write a cron job to do the retrieve on a scheduled basis, but that is probably a separate question.
    – Phil Rymek
    Jul 20 '15 at 14:59
  • This solution works, but hoped that we could do this on a regular basis automatically! :( Jul 23 '15 at 5:43
0

According to the Apex Docs:

Custom labels are not standard sObjects. You cannot create a new instance of a custom label. You can only access the value of a custom label using system.label.label_name. For example:

String errorMsg = System.Label.generic_error;

It would seem there's no way around passing the value of the label_name through the system method in order to dynamically get the custom label.

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.