+ Start a Discussion

SOQL Relationship Query for User fields

I may be going crazy but trying to pull in joined User fields appears to work only for a few fields like FirstName, LastName and Alias.  All other standard and custom fields appear to the API as non-existent and return an error.

This query works fine:
Select Id, Task.Owner.FirstName from Task where Task.Id = '<some Task Id>'

But this one does not:
Select Id, Task.Owner.City from Task where Task.Id = '<some Task Id>'

result: non-existent field error on City.

This does not have anything to do with field-level-security because you can't set FLS on the User object.

What is happening here?

See this thread for more info.  I had the same question.  Basically, when an Owner can be set to a User or Queue, a virtual "Name" object is used instead of User. 

Search for "Understanding Polymorphic Keys and Relationships" in the API doc.
Thanks, Hemm.  Exactly the info I was looking for.  That explains a lot.