function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RamyaKrishnaRamyaKrishna 

Reg: Finding the objectname using object Id.

Hi,

 

I knew object id 'a03/0' like this.

By using this id, How can i know the object name like E__c.

 

Regards:

Ramya

 

Ritesh AswaneyRitesh Aswaney

Hey, here's a link to a post which answers this

(http://boards.developerforce.com/t5/Apex-Code-Development/How-to-get-the-object-API-name-by-Id/m-p/258405#M44940

- the gist is

String accId = '00190000005gJcl'; // replace this id with your one

String keyCode  = accId.subString(0,3);

Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
for(Schema.SObjectType objectInstance : gd.values())
{
if(objectInstance.getDescribe().getKeyPrefix() == keyCode)
{//do your processing with the API name what you want
System.debug('Id is related to object: '+ objectInstance.getDescribe().getName());
}
}