function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
virago81virago81 

SOQL Relationship Query for User fields

Guys,
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.

Example:
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?


hemmhemm
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.
virago81virago81
Thanks, Hemm.  Exactly the info I was looking for.  That explains a lot.