Tuesday 3 June 2014

How to get Object API Name in salesforce through apex code


Through User Interface

To Know Standard Object API Names follow this below link,
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_list.htm

To Know Custom Object API Names

Go to Setup--> Build --> Create --> Object --> Click the Object Name --> then you will find the API Name.

Through ApexCode

If you want to retrieve object label and API Name via Apex coding means you can use the following code,
01List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();    
02 
03Map<String,String> objName = new Map<String,String>();
04for(Schema.SObjectType f : gd)
05{
06    if(f.getDescribe().isCustom())
07    {
08    objName.put(f.getDescribe().getLabel(),f.getDescribe().getName());
09    }
10}
11 
12System.debug('Object Names'+objName);

1 comment:

Activities: Assign Tasks to a Queue Salesforce Lightning

Salesforce announced to assign Tasks to a Queue beginning from Spring'20 release. How does it work? In Setup, enter Queues in th...