So, I have Tag_Case__c Object. this object has relationship with Case Object I wanna get SmallPhotoUrl data from Case Owner

I was tried use something like this following code, but it not works

SELECT ID, Case__r.Subject, Case__r.Owner.Name, Case__r.Owner.SmallPhotoUrl FROM Tag_Case__c

and Also

SELECT ID, Case__r.Subject, Case__r.Owner.Name, (SELECT Case__r.OwnerId FROM User__r) FROM Tag_Case__c

But still erro. Actually, I can get this field Case__r.Owner.Name. but error when I put this field on select condition Case__r.Owner.SmallPhotoUrl

Anyone can help me please. Thanks in advance

  • 1
    Welcome to SFSE! When you're getting an error message, you should include the full text of the error message (don't try to paraphrase it). It'll also help to know how your objects are related here. Do you have a Case__c relationship field on your Tag_Case__c SObject, or is it the other way around (your Case object has a Tag_Case__c relationship field)? Please edit your question to add those details.
    – Derek F
    Apr 29, 2021 at 11:14
  • I was done with this issue. I just combine the data from apex code. Thanks @DerekF
    – naticap
    May 4, 2021 at 21:51

1 Answer 1


Case Owner is a Name-pointing field, because a case can be owned by a User or a Queue (Group). As such, the Name object allows common fields to be exposed in SOQL, such as Name, Email, etc, but not some standard and any custom user fields.

You can use a formula field to expose the value: Case__r.Owner:User.SmallPhotoUrl (note, this means you need to create a custom field, SOQL alone won't get you there).

You can use TYPEOF to get the data: SELECT TYPEOF Case__r.Owner WHEN User THEN SmallPhotoUrl END FROM ....

Depending on what exactly you're doing, you might just choose to use two queries instead of one.

  • I was done with this issue. I combine the data from apex code. so, first I query on user, then I join user data with case data as Map object. Thanks @sfdcfox.
    – naticap
    May 4, 2021 at 21:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .