You need to sign in to do that
Don't have an account?
Ofra
How to find an object type's id in Apex or SOQL?
Hi,
I'm writing some Apex code and I need to query a custom object's ID as in the URL below:
I want the ID because I want to query the correct Custom Metadata Record that corresponds to this type via an Entity Definition Relationship field. I can see in the Query Editor Results that the value stored in the record is not the type's name, but the type's ID. So I would like to get the ID so that I can construct the correct where clause.
I'm writing some Apex code and I need to query a custom object's ID as in the URL below:
https://telfed--pras.lightning.force.com/lightning/setup/ObjectManager/01I3q0000026FS5/Details/viewWhat I have is the ID of a record of that type, and I know how to get the type's name, for example by doing:
recordId.getSobjectType().getDescribe().getName()However, I can't seem to find a function that will get me the ID of type.
I want the ID because I want to query the correct Custom Metadata Record that corresponds to this type via an Entity Definition Relationship field. I can see in the Query Editor Results that the value stored in the record is not the type's name, but the type's ID. So I would like to get the ID so that I can construct the correct where clause.
SELECT FIELDS(ALL) FROM Incoming_Contact_Data__mdt LIMIT 200Any help would be appreciated!
I can query by the name by using:
All Answers
Try Below Line Please Mark It As Best Answer If It Helps
Thank You!
I can query by the name by using: