0

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?

8
  • Where you will use the button? Jul 23, 2019 at 12:39
  • In the lightning web component. for App exchange app.
    – akashg7
    Jul 23, 2019 at 13:00
  • And the Lightning component will be used On record page or home page or App Page? Jul 23, 2019 at 13:02
  • Lightning web component will be used on the app page!
    – akashg7
    Jul 23, 2019 at 13:03
  • I think '/lightning/setup/ObjectManager/Object_Api_Name/FieldsAndRelationships/new' will work if you pass the object api name dynamically. Jul 23, 2019 at 13:05

3 Answers 3

1

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

1
  • It's not working!
    – akashg7
    Jul 24, 2019 at 5:50
0

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.

1
  • I have done that too but the requirement is to only give button which will redirect to that page.
    – akashg7
    Jul 24, 2019 at 5:40
0

Just got to know we can query like this. Got the result using this-

SELECT DurableId FROM EntityDefinition WHERE QualifiedApiName = 'CustomObject__c'

You must log in to answer this question.

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