I'm trying to write a SOQL query that will grab one of the Contact object's standard fields "Contact Owner", which is a Lookup(User) field:
The field name is "Owner", but when I try to query
SELECT Contact.Owner FROM Contact
I get an error stating that there is no such field.
SELECT Contact.Owner, Contact.Name, Contact.Rule_Class__c
^
ERROR at Row:1:Column:8
No such column 'Owner' on entity 'Contact'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.
How can I grab this field?
Thank you!
That's a normal behavior for Relation fields
You can imagine OwnerId
as an alias
SELECT LastModifiedBy.Name, LastModifiedBy.Id, LastModifiedById FROM Contact
SELECT CreatedBy.Name, CreatedBy.Id, CreatedById FROM Contact
Also use Workbench or Developer console or Eclipse to construct your queries instead of using salesforce setup interface
Workbench
Developer Console
This is strange:
"Select c.Owner.Email, c.Owner.Name, c.Owner.Username, c.OwnerId From Contact c Run the above in Developer Console--Query Editor"
I wonder why Contact.Owner comes up as non-existent but Contact.Owner.Name is?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.