[SalesForce] Finding a Custom Object Id (01I…) to get the Setup page URL

I'm trying to find a way to get the "Id" for a custom object's setup page. So I'm NOT trying get a record Id. I'm working on a custom visualforce page and I'm setting up a link so that when the user clicks it, it'll direct them to the object's setup page. I've included a picture below to show what I'm am trying to get.

screenshot

Does anyone know of a way to query for that Id through Apex? I tried using the describe methods, but had no luck…

Any help/tips would be greatly appreciated!

  • Ryan

Best Answer

Update

We can now query those 01I object ids and 00N field ids directly without Tooling API or callouts.

List<EntityParticle> entities = [
    SELECT DurableId
    FROM EntityParticle
    WHERE EntityDefinition.QualifiedApiName = 'MyCustom__c'
];

This will return:

DurableId
01I7F000001fbTC.LastViewedDate
01I7F000001fbTC.LastReferencedDate
01I7F000001fbTC.00N7F00000HnXIU
01I7F000001fbTC.00N7F00000HnXIW
...

Much easier than the historical solution - and no Session ID involved or API privilege issues.