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
MonaliDMonaliD 

Getting Object id

Hi,

 

In the following URL

"/setup/ui/recordtypeselect.jsp?ent=01I900000003zgn"  '01I900000003zgn ' represents id of an object .

 

Is there  way to get this object id so that i can use this URL on custom button's action. I want to redirect user to standard create New page similar to the New Button in related list.

 

My object has record type thats why I cant use objectprefix/e

 

Thanks,

Monali

Ankit AroraAnkit Arora

If you want to get the object name with Id then here is the code :

 

String objectId = '00190000006TqvN' ;
//ObjectId of which type needs to be extracted
System.Debug(' ::::::::::: ' + objectId);

//get all of the objects from your org
Map<String,Schema.SObjectType> gd = Schema.getGlobalDescribe();
Map<String, String> keyPrefixMap = new Map<String, String>{};
//get the prefix of the objects in Ids
Set<String> keyPrefixSet = gd.keySet();
for(String sObj : keyPrefixSet)
{
Schema.DescribeSObjectResult r =  gd.get(sObj).getDescribe();
String tempName = r.getName();
String tempPrefix = r.getKeyPrefix();
 //in this map, all the Objects with their prefixes will be stored
keyPrefixMap.put(tempPrefix,tempName);
}

System.debug('keyPrefixMap :::::::: ' + keyPrefixMap) ;

 This keyPrefixMap contains prefix of object Id and the object name. You can use it in any way you like.

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page