You need to sign in to do that
Don't have an account?
Sumant Kuchipudi
How can we get Object name by ID using SOQL?
Hi,
I can get the Object name with the following code but how can I get this objName using SOQL?
I can get the Object name with the following code but how can I get this objName using SOQL?
String objName = recId.getSObjectType().getDescribe().getName()I'm using java/python code to call SOQLs for some other work (integration) I need to know the object names by record ids in Java/Python. Please advice
I do not think you can do this in SOQL, but as Arvind said, you can query the record ID of the object. The key prefix is the first 3 characters of the record ID. This key prefix will actually tell you the object type of the record, so if you have a map of key prefixes and their matching object types, you can just lookup the key prefix to find the object type.
All Answers
You can easily get the object Name from Record Id:
Use it, if you have any query, you can contact me.
Thanks,
Arvind Kumar
I know how to get obj name from APEX but I'm trying to get it from Java/Python which doesn'r have Schema kinda apex apis so I was looking for an option from SOQL. Please advice
I do not think you can do this in SOQL, but as Arvind said, you can query the record ID of the object. The key prefix is the first 3 characters of the record ID. This key prefix will actually tell you the object type of the record, so if you have a map of key prefixes and their matching object types, you can just lookup the key prefix to find the object type.
FROM EntityDefinition
ORDER BY QualifiedApiName ASC
LIMIT 2000 OFFSET 0
Caveats:
• does not support queryMore which means the largest single pull can be 2000 (reason for the LIMIT statement above)
• overcoming the queryMore limitation can be achieved by simply pulling multiple times (reason for the OFFSET statement above)
LIMIT 2000 OFFSET 2000 (means pull 2000 and start at 2000 = would result in records 2000-4000 from your Org)
[my experience is less than 10k records for some well sized Enterprise Orgs which would equate to 5x pulling this query and adjusting the offset]
Alternatively:
filter resultset using a 'where' clause like below, preferrably something that limits resultset to fewer than 2000 records