Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Salesforce by (11.9k points)

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:

enter image description here

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!

1 Answer

0 votes
by (32.1k points)

That's a normal behavior for Relation fields

enter image description here

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 enter image description here

Developer Console enter image description here

Browse Categories

...