8

Is it possible to use a subquery to obtain a list of that object's __Share's?

For example: ObjA has been manually shared via apex. At some point I may want to query information about ObjA and get a list of its shares. I'd like to be able to do something like this:

[Select 
    Id,
    Name,
   (Select Id, UserOrGroupdID FROM ObjA__Shares) 
From 
    ObjA__c Where Id = :someId];

From my testing in the dev console, it doesn't not appear to be the case. For the record I've tried ObjA__Share and ObjA__Shares to no avail.

Thanks

1 Answer 1

13

This is perfectly possible. You are just using the wrong syntax.

This will work:

SELECT ID, Name, (SELECT ID, UserOrGroupdID FROM Shares) FROM ObjA__c WHERE ID = :someId;

In order to find the right child relationship names, I always use the Schema Explorer in Eclipse. By browsing to an object and then selecting 'Child Relationships' you can find out the 'Relationship Name' of the child relationship.

1
  • 1
    Thanks! That'll do nicely. I'm not an Eclipse user but that's darn good to know. I'd vote you up but I don't quite have enough rep yet! Commented Oct 2, 2014 at 20:04

You must log in to answer this question.

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