0

I want to get the custom object id using the custom object's API name. Please tell me the way how to get id.

enter image description here

req.setEndpoint(domainUrl+'/services/data/v46.0/tooling/query?q='+
                        'SELECT+Layout.Name'
                        +'+FROM+ProfileLayout'
                        +'+WHERE+ProfileId='+'\''+profileId+'\''
                        +'+AND+TableEnumOrId='+'\''+aaa+'\'');
    ```

  • 1
    Why do you want the SObjectType Id? What's the use case? – Brian Miller Jul 24 at 8:17
  • 1
    @BrianMiller Hi. In the case of a standard object, set the API name to 'TableEnumOrId'.For custom objects, I must set SObjectType instead of API name. – S Kawasaki Jul 24 at 8:42
1

You can get it from the Tooling API itself. The Tooling API field you want is EntityDefinition.DurableId:

SELECT DurableId FROM EntityDefinition WHERE QualifiedApiName = 'Full_Name_of_Field__c'
  • Thank you for your help!! It worked!! – S Kawasaki Jul 25 at 1:17
0

Not sure what you meant by getting Id from object name.

Here is small notes on Ids and object API names.

You can get object API name by using Id. You can say myId.getSobjectType(). If you want to know all the objects' Ids then use SOQL [SELECT Id FROM ObjectName].

  • Thank you for your kindness. But what I want to get is not the record's ID but the custom object's ID. When you open the object manager page, an ID that is not a record ID is displayed. – S Kawasaki Jul 25 at 0:50
0

S Kawasaki,

You can queried for you custom object using SOQL:

List<MyCustomObject__c> customObjs = [SELECT Id, Name, CustomField__c FROM MyCustomObject__c];

Hope this helps!

  • Thank you for your kindness. But what I want to get is not the record's ID but the custom object's ID. When you open the object manager page, an ID that is not a record ID is displayed. – S Kawasaki Jul 25 at 0:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.