+ Start a Discussion
Frank NeezenFrank Neezen 

How to get the 15-digit Salesforce ID of a Custom Object



I am trying to find how to locate the 15-digit Salesforce ID of a given custom object. I need this to dynamically create a record type selection link:


/setup/ui/recordtypeselect.jsp?ent= <Salesforce_ID_Of_Custom_Object>


For standard objects its fine to simply enter the object name in the 'ent' parameter, but for custom objects it requires the Salesforce ID (which is the one you find if you look at the URL when editing that particular object. I understand getKeyPrefix() within the DescribeResult gives you the first three digits but there does not seem to be a way of getting the entire 15-digit ID. 


Hope someone can help me out. 


Hey Frank ,


If you really need a 15 Digit ID then go to Setup >> Under Custom object . CLick on the Desired Custom object ,then check for URL . 


It should be something like this : https://tojoshimayank-dev-ed.my.salesforce.com/001I9000000XXXX?setupid=CustomObjects 


The value 001I9000000XXXX is a 15 Digit ID for your Custom Object . Now you can confim it by just run this type of URL as below :


https://tojoshimayank-dev-ed.my.salesforce.com/001I9000000XXXX . It will entually open up the Object which is correspond to this ID . 


I hope that will help , if yes then mark this as Solution . :) 


However, using Code (i mean Apex) it is still not possible to get Custom Object ID . 


Thanks ,

Frank NeezenFrank Neezen

Hi Mayank,


Thanks. I know where I can find the 15-digit ID, which is what I explained in my question however I need to be able to fetch it from within my class. I would like to know if anyone knows if its hidden within the GetDescribeResult or within some table similar to RecordTypes ? 


Hopefully someone has the solution!


NP , in APEX there is no such API call to fetch Custom Obj ID . But , I keep an eye on this forum if there is any Way .



Frank NeezenFrank Neezen

No worries, thanks ! I fail to understand why the Force.com platform does not seem to allow you to something like this in an elegant manner. 


Anyone else know the answer? Thanks


There were lot more things that Salesforce needs to update. You can promote this as an Idea in IdeaExchange or can create fresh Idea (with Business Requirement) . 


Also, I found out  using  describeSObjects() call we can utilize urlDetail Property . If we can strore this value as an String and able to truncate its value to the desired One (some how ) ,then it is somewhere possible(It's a blind Guess)  . 




Frank NeezenFrank Neezen

Hi Mayank,


Thanks for replying but sadly that's not working either. The only way I can see perhaps is setting a PageReference to the custom object page and try to get it from the page source or something.


Any word from the SFDC guys on the forum regarding this ? Why is it so hard to get the Salesforce ID of a Custom Object? Clearly this should be easier.


Hi Frank,


The 15/18 digit id uniquely identifies a record, be it standard or custom. Most people obtain an id by using a query since the other fields on the object are like to be known. 


It's like algebra, solve for the unknown value. id = <some criteria in a query>. What it feels like your asking is how do I identify a record with no other input. I don't know how you are using that recordtypeselect.jsp resource, but it is certainly not an API and is bound to break without warning sometime in the future as we reserve the right to change stuff that is not an API.


Having said that, if any old id would do, then you can query for a custom object and set the limit to one to make it very light and use that id to HACK the jsp page.


I would be interested in what your are trying to do and why the API doesn't work for you.



Frank N.Frank N.

Hi Dave,


I logged in using my other account. Anyway - how would querying for a custom object work? Basically what I am trying to do is pre-populating fields on a 'new object' page when users create records of a particular kind. Furthermore, before for some objects I want to be able to have the user first select the record type required, before the fields get pre-populated.


Now - the script is working fine except for the record type selection page. I understand by default SFDC redirects users to a page called '.. / recordtypeselect.jsp?ent = <etc etc > ' (you can see this when you try to create a record of a custom object that has multiple record types. Now the question is: how to resolve the 'ent' value in my custom script which by SFDC logic is the ID of the custom object (not a record of the object, but the actual object ID. 


I am not trying to identify a record with no input since its not the record of an object I am after, I am after the ID that one can see if you go to create => objects => custom object, and then if you look at the URL, there is an ID after the /. Thats the ID I need !


Do you have any advice how the API could accomodate? 

Thanks Dave.





Hopefully DevAngel is reading this too.


I know this is the wrong thread to put my post on,

however I'd like some help from someone "in the know"

and having stumbled upon a DevAngel post from 2007,

titled "Using Triggers to automatically create a contract",

I thought I could use some of that expettise :)


Anyways, I would appreciate some pointers about

the following trigger scenario:


1.) Upon creating a new "Account" object / record (what's

      the difference?), a trigger needs to create a new Contact

      object / record that would be associated with that new Account.


2.) Let's say an Account has a "Phone Number" field. Now, If such

      an Account has several "child-Contact(s)", then upon modifying the

      value (or phone number) in this Account's "Phone Number" field. then

      some other trigger should update all  "Phone Number" field(s)

      for each and every one of that Account's "child-Contact(s)" as well,

      with the same phone number as that of the Account.


NOTE : I have NOT been lazy... I only started with SalesForce a few days ago,

              and so far have been looking at their documentation and that of others;

              I even completed some "Step-by-Step" tutorial about creating a whole APP,

              meaning, creating a new object (via the GUI), then a static class with some

              method in it, then a trigger to call that method, then a Test class, and then

              had the whole thing run and output some messages on the run log or whatever.


               It's just that, AFAIK, the Account + Contact objects may be built-in, and therefore

               limited to any code reference from the outside, namely, custom objects?


               Plus, it seems, that new triggers are only to be created for and saved within

               custom objects, namely, ones that I am to create separately and therefore

               such triggers cannot be made available for either Accounts or Contacts?



Any code-wise help would be greatly appreciated.

Thanks in advance,




Ilene JonesIlene Jones


Did you ever receive an answer to this question?  I am trying to do the same thing and hoped the end of the thread would have an awesome answer, but I can see that it does not.  Any thoughts on this would be greatly appreciated.  I have the feeling that I will need to do this through a visual force page - right now I'm just trying it through a custom button, which almost does it - with the exception of getting that object ID that I need.  

I don't want to hard code the custom object ID, since I'm developing in the sandbox and plan to move it over to production, which will end up with a new custom object ID.


Tuan VoTuan Vo
You can try this way, it works for me:
SELECT CustomObjectId FROM CustomObjectUserLicenseMetrics  where CustomObjectName = 'Object_Name';

Example the Apex code:
 List<SObject> customObjectIdList = [SELECT CustomObjectId FROM CustomObjectUserLicenseMetrics  where CustomObjectName =:'Object_Name' LIMIT 1];
        String mylObjectId = '';
        if(customObjectIdList.size() > 0)
            mylObjectId = (String)customObjectIdList[0].get('CustomObjectId');

Abdulla d 5Abdulla d 5
SELECT DurableId FROM EntityDefinition WHERE QualifiedApiName = 'CustomObjectName__c' the durableid is the id of the object
Thanks, Abdulla!