Use Case

  1. Account Contacts have a Field For Department
  2. Case OWD set to Private
  3. No Sharing Set

** Need to be able to provide access to a case created by a contact ONLY with other contacts on the same account with the same department. **

Sharing sets are an all or nothing. Case Teams Do not work There is no ability for Apex Sharing for Community Users.

My only thought is using visual force to override everything.

Does anyone have any workarounds that they can think of?

  • Oh boy, this was a longg time ago.. Wouldn't of gave a answer if I knew that – EricSSH Jan 16 '15 at 19:23
  • @EricSSH - No worries, any answer no matter when is a good one. Unfortunately the project is over and I do not even recall which project this was for....We resolved it with business process changes I believe as they did not want code to do it.... – Eric Jan 16 '15 at 19:31

I created a trigger to share my cases, this may or may not help you, This will share the case to the partner user that created it, along with the group he is in

trigger PartnerCaseSharing on Case (after insert, after update) {

    Map<id,User>PartnerUsermap = new Map<id,user>([select id,UserType from user where UserType = 'PowerPartner' and isActive = true] );     
    List<GroupMember>GroupMemberList = new List<GroupMember>([select GroupId,UserOrGroupId from GroupMember]); 
    List<CaseShare> CsShareList = new list<CaseShare>();

         for(Case cs : trigger.new){ 
                    for(GroupMember grpmem : GroupMemberList){
                        if(grpmem.UserOrGroupId == cs.CreatedById){   
                            CaseShare  csshare = new CaseShare (CaseId = cs.id,UserOrGroupId = grpmem.GroupId,CaseAccessLevel = 'Edit');                         
        Database.SaveResult[] lsr = Database.insert(CsShareList,false);           
        Integer i=0;
        for(Database.SaveResult sr : lsr){
                Database.Error err = sr.getErrors()[0]; 
                if(!(err.getStatusCode() == StatusCode.FIELD_FILTER_VALIDATION_EXCEPTION  
                                               &&  err.getMessage().contains('AccessLevel'))){

                       'Unable to grant sharing access due to following exception: '
                       + err.getMessage());

Case Teams Do not work There is no ability for Apex Sharing for Community Users.

Why Case team does not work ?

A community user is actually associated to a contact, therefor in case team you don't have to add your community user as a case team member, but you have to search for his contact

  • I have them in there as a Contact on the case team with Read/Write access. On viewing the related list for case team the Case Access is --. Case Team for a Contact only works if the Contact can log in as a Customer Portal User not a community User. Per the documentation and my own testing "Contacts can only view cases via a Customer Portal." and the link to the document is here: help.salesforce.com/apex/…. – Eric Apr 30 '14 at 2:54
  • 2
    I have tested with this implementation and the Community User does not have access to the case even though they are on the case team as a contact and it is set to read/write access on the case team member record – Eric Apr 30 '14 at 2:55

I just stumbled upon this question and it might be late to answer it now. But you could still use Sharing Set and a trigger to achieve that. Sharing sets work with custom Lookup fields as well. So, you could create a custom Lookup(Contact) field on case. Hide that field from the layout. In the sharing set, match user's contact with this new field on case to provide access. Now, within a trigger on case, you could write your business logic to update the lookup field depending upon whether the current contact on the case needs access or not.

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.