Finding a Custom Object Id (01I...) to get the Setup page URL

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.

Tags:

Apex

Id

Sobject