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
diathesisdiathesis 

Cases with associated owning users (Null ChildRelationship.relationshipName)?

I'd like a single query that would get me a list of cases, and if the case owner is a user, the name and username of said owner.  Is that possible in SOQL?

I started by getting a list of Cases, and traversing to Owner, but the only way to get username that way is to verify that Owner.type is 'User' and then issue a second query for the username.  There doesn't seem to be an easy way to get a list of associated users instead of Name objects.

I then moved up to User and tried to query down to Case.  The Apex developer tools indicated there were three Case relationships but simple queries didn't seem to work, so I tried a describeSObject call, which got me these three relationships (relationshipName: childSObject.field)
  null: Case.CreatedById
  null: Case.LastModifiedById
  null: Case.OwnerId

The relationship name for each of these is blank, so as far as I can tell, I can't actually use that relationship -- is there a way to use an anonymous relationship that I haven't yet discovered?

Thanks,

  - Geoffrey