1

I need to get the owner's information when I run query for other salesforce object.

For example, I am able to run the query [SELECT owner.email,owner.phone FROM task] successfully.

However, the query [SELECT owner.email,owner.phone,owner.mobilephone FROM task ] is failed and the error message shows "No such column 'mobilephone' on entity 'Name'. 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."

I didn't find any documentation in salesforce about this limit.

Any Ideas?

Thanks!

  • Interesting that the Force IDE .schema view suggests that the Owner field is a reference to a User but not all User fields appear to be queryable in this way. Perhaps someone has an explanation... – Keith C May 23 '14 at 17:51
  • You should have any field on user. It seems likely that you have a syntax error in your code that we can't see. Can you post it exactly as it appears? – greenstork May 23 '14 at 17:53
  • if you run SELECT email,phone,mobilephone FROM user, it works, however, SELECT owner.email,owner.phone,owner.mobilephone FROM task doesn't work – David May 23 '14 at 18:02
2

I found this interesting link and superfell's answer may explain the issue you see: https://developer.salesforce.com/forums/ForumsMain?id=906F00000008wAvIAI

Owner on Task is a polymorphic relationship (i.e. to can be a foreign key to different types), for these types of relationships only a subset of data of the related object is exposed, these are fields defined on the Name entity, including firstName, lastName & phone, but not all fields from user. From the schema you can see this because the ownerId field has the isNamePointing property set to true(hence you can see this in the schema). There's also a give-away in the error message where it says the field is not valid for the Name entity. This is all covered in the SOQL-R section of the API documentation.

So if you cannot do it the above way how do you do it? See this link : https://developer.salesforce.com/forums/?id=906F00000009EkBIAU

Summary of how to do :

  • Query for the Tasks you care about
  • Loop through the results and compile a set of User ID's
  • Query for data on the users matching the compiled set of ID's
  • Run your logic on the Tasks you retrieved, using the User ID to look up the associated user information when needed
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.