I actually can't believe I've not come across this before now, but is there a way of following on the
owner relationship on a
Task to get some other field on the
For an example, say on the
User object there is a custom field called
MyField__c, and I want to query that while querying tasks:
select Id, Subject, Owner.MyField__c from Task
Seems easy, but the
Owner field is one of those polymorphic lookups peculiar to tasks and activities, as tasks can also be owned by a calendar. If you create a formula field you can follow the relationship using this syntax:
which again, is something I've not seen until now but it's easy to see that
:User is qualifying the relationship type. This syntax does not parse in SOQL, so the question is, is there an alternative syntax that does work?
Obviously I can just create the formula field and query by that, but I'm curious to know if there is a way of properly traversing this relationship in SOQL.