Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
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! –  lifewithryan 13 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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