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.
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>
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.