15

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

1 Answer 1

15

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.

3
  • Thank you, that was exactly what I was looking for. I have another question. I had to set a remote site (the site I used was the one given to me by Url.getSalesforceBaseUrl() ) manually. Do you know a way to set a remote site dynamically or a way to find an even more generic web address that I could set as the remote site? I'm looking for something that'll work across different instances and not require the user to manually set the remote site for every different instance.
    – user7702
    Apr 7, 2014 at 21:30
  • @user7702 Maybe in lieu of a callout you can get creative with PageReference.getContent() and a relative URL which doesn't require a Remote Site Setting. Apr 7, 2014 at 22:17
  • Great answer, but the syntax is out of date, Always refer to the latest SF official document on this for syntax: developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/…
    – Joe
    Sep 12, 2018 at 17:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .