You need to sign in to do that
Don't have an account?
Alden Gordon
SOQL queries from objects with multi-word names
I am attempting to execute a simple SOQL query on objects with two-word names, and it is proving surprisingly difficult.
The query below works fine:
"select name from user limit 10"
I want to execute something similar on an object called "User Emails" - I know that is the name as it was pulled from the schema builder. However, any simple query on this table fails, no matter what format of the two-word name I try.
For example:
"select date from user_emails limit 10"
This fails with the error "Object type 'user_emails' is not supported". This is true of any format of the object name I have tried (useremails, UserEmails, user-emails, etc).
What is the correct way to query these objects?
The query below works fine:
"select name from user limit 10"
I want to execute something similar on an object called "User Emails" - I know that is the name as it was pulled from the schema builder. However, any simple query on this table fails, no matter what format of the two-word name I try.
For example:
"select date from user_emails limit 10"
This fails with the error "Object type 'user_emails' is not supported". This is true of any format of the object name I have tried (useremails, UserEmails, user-emails, etc).
What is the correct way to query these objects?
You will have to use API name in SOQL to get this work. To get API name for a custom object go to the setup->Build->Create->Objects. Click on the object "User Emails" from the list. Get the "API Name" from there and use that in your SOQL.
All Answers
So your query will look like this. Notice __c in the for the field name and the object name. these are API names of the object and the field that needs to be used in the query.
select date__C from user_emails__c limit 10
If you are trying to get the email Id from the user object you will need to use the below query.
select Email from user limit 10
Good Luck!!
You will have to use API name in SOQL to get this work. To get API name for a custom object go to the setup->Build->Create->Objects. Click on the object "User Emails" from the list. Get the "API Name" from there and use that in your SOQL.
Hello Alden ,
Object name is different and api name is different while using Apex code we have to use API names. To find the api for any object or field goto the object detail page and pick the API name .Setup->Build->Create->Objects->API Name for Fields Setup->Build->Create->Objects->Fields->API Name.
In your case try with try select date from user_emails__c limit 10.