1

Currently with this trigger I created, if a portal user creates a commission split it will be shared with the group that the portal user is in. Recently they told me that it needs to be shared with multiple other users so they can go through the approval process. Is there anyway I can edit my current trigger to do this?

 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<Split__Share> CsShareList = new list<Split__Share>();

if(!PartnerUsermap.isEmpty()){
     for(Split__c cs : trigger.new){  
            if(PartnerUsermap.containsKey(cs.CreatedById)){
                for(GroupMember grpmem : GroupMemberList){
                    if(grpmem.UserOrGroupId == cs.CreatedById){   
                        Split__Share  csshare = new Split__Share (ParentId = cs.id,UserOrGroupId = grpmem.GroupId,AccessLevel = 'Edit');                          
                        CsShareList.add(csshare);                           
                    } 
                }

I need to add the following Reps to the sharing logic.. I'm having a hard time figuring out the logic and process. Does anyone have any insight?

enter image description here

3
  • I suspect the key to doing what you desire is going to be in how you query your user map with which to create the splits. If the additional reps are always the same, or known based on certain criteria, they can be added to your initial queried map using standard map methods. That would seemingly allow you to salvage your existing code.
    – crmprogdev
    May 29 '14 at 3:53
  • So I figured out how to do it, and I pretty much did what you said, I'm just trying to figure out to edit my test class now
    – EricSSH
    May 29 '14 at 15:49
  • Glad to hear that approach worked for you. :)
    – crmprogdev
    May 29 '14 at 18:38
0

The key to doing what you desire will be in how you query the user map you're using to create the splits. If the additional reps are always the same, or known based on certain criteria, they can be added to your initial queried map using standard map methods. That would presumably allow you to salvage most of your existing code.

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.