How to get custom object id dynamically. I have created one button on UI called Create custom field and on click of that button, I want to redirect it to that custom object field creation page(object manager->field and relationships-> new). I cannot give hardcoded id to that link and also it's not taking API name. for API name its showing insufficient privileges. Is it possible using tooling API? and How?
you may try to use the following SOQL Query to get the Id:
Id myCustomObjectId = [SELECT CustomObjectId FROM CustomObjectUserLicenseMetrics WHERE CustomObjectName ='MyCustomObjectName' limit 1].id;
hope it helps
yes instead of getting the id of the object and redirecting the page to create a custom field, you can create a field using Tooling api itself. I have written a lightning component to create custom object fields for any object (Whichever is accessible to create custom fields). Let me know if you need the code.
Just got to know we can query like this. Got the result using this-
SELECT DurableId FROM EntityDefinition WHERE QualifiedApiName = 'CustomObject__c'