3

I have an exhaustive list of custom objects whose API Names and labels does not match. I end up opening each object in order to determine if the label has matching API Name.I want to see the API Name displayed along with label on the result page of custom Objects. Is there a better way to get label for a custom object when its API Name is known?

14

You can get the label using the DescribeSObjectResult:

DescribeSObjectResult describe = SObjectType.MyApiName__c;
system.debug(describe.getLabel());

Another common syntax is:

DescribeSObjectResult describe = MyApiName__c.sObjectType.getDescribe();

You can also just one-line it:

system.debug(SObjectType.MyApiName__c.getLabel());
|improve this answer|||||
  • I am looking to do it from the platform, not from the code. A soql query will also help. – smhvrtyj Jul 27 '16 at 18:40
  • You cannot use a query. What do you mean by from the platform? – Adrian Larson Jul 27 '16 at 18:42
  • When I log into my org I do a search for objects which has more than 500 objects. I know the API Name and want to navigate to that object but I end of opening each object to see if that is the object I am looking for or not. – smhvrtyj Jul 27 '16 at 18:56
  • 1
    You are really not making yourself clear. Sorry. – Adrian Larson Jul 27 '16 at 18:57

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.