Skip to main content
replaced http://salesforce.stackexchange.com/ with https://salesforce.stackexchange.com/
Source Link
added 175 characters in body
Source Link
Keith C
  • 137.3k
  • 29
  • 218
  • 458
added 365 characters in body
Source Link
BarCotter
  • 12.4k
  • 4
  • 38
  • 58

public class UpdateCSM{
public static void updateTeamMember(List accounts){
List ashareLIST = new List();
List ATM = new List();
Set rmMember = new Set();
Map<ID, ID> acctToBRepMap = new Map<ID, ID>();

for(Account a:accounts){

AccountShare caSharingRule = new AccountShare();
caSharingRule.AccountId = a.Id;
caSharingRule.OpportunityAccessLevel = 'Edit';
caSharingRule.CaseAccessLevel = 'Edit';
caSharingRule.AccountAccessLevel = 'Edit';
caSharingRule.UserOrGroupId = a.Customer_Success_Manager__c;
ashareLIST.add(caSharingRule);

if(a.Customer_Success_Manager__c!= null){
AccountTeamMember Teammemberad=new AccountTeamMember(); Teammemberad.AccountId=a.id; Teammemberad.UserId=a.Customer_Success_Manager__c; Teammemberad.TeamMemberRole = 'Customer Success Manager';
ATM.add(Teammemberad);

if(!ATM.isEmpty()){
insert ATM;
insert ashareLIST;
}
}
}
}
}

public class UpdateCSM{        
    public static void updateTeamMember(List<Account> accounts){            
        List<AccountShare> ashareLIST = new List<AccountShare>();            
        List<AccountTeamMember> ATM = new List<AccountTeamMember>();            
        Set<String> rmMember = new Set<String>();            
        Map<ID, ID> acctToBRepMap = new Map<ID, ID>();            
    
        for(Account a:accounts){   
                     
            AccountShare caSharingRule = new AccountShare();                   
            caSharingRule.AccountId = a.Id;                   
            caSharingRule.OpportunityAccessLevel = 'Edit';                   
            caSharingRule.CaseAccessLevel = 'Edit';                   
            caSharingRule.AccountAccessLevel = 'Edit';                   
            caSharingRule.UserOrGroupId = a.Customer_Success_Manager__c;                   
            ashareLIST.add(caSharingRule);                       
        
            if(a.Customer_Success_Manager__c!= null){                 
                AccountTeamMember Teammemberad=new AccountTeamMember();
                Teammemberad.AccountId=a.id;
                Teammemberad.UserId=a.Customer_Success_Manager__c;
                Teammemberad.TeamMemberRole = 'Customer Success Manager';                  
                ATM.add(Teammemberad);          
    
                  if(!ATM.isEmpty()){              
                      insert ATM;                          
                      insert ashareLIST;                                 
                  }               
            }                
        }                
    }              
}

public class UpdateCSM{
public static void updateTeamMember(List accounts){
List ashareLIST = new List();
List ATM = new List();
Set rmMember = new Set();
Map<ID, ID> acctToBRepMap = new Map<ID, ID>();

for(Account a:accounts){

AccountShare caSharingRule = new AccountShare();
caSharingRule.AccountId = a.Id;
caSharingRule.OpportunityAccessLevel = 'Edit';
caSharingRule.CaseAccessLevel = 'Edit';
caSharingRule.AccountAccessLevel = 'Edit';
caSharingRule.UserOrGroupId = a.Customer_Success_Manager__c;
ashareLIST.add(caSharingRule);

if(a.Customer_Success_Manager__c!= null){
AccountTeamMember Teammemberad=new AccountTeamMember(); Teammemberad.AccountId=a.id; Teammemberad.UserId=a.Customer_Success_Manager__c; Teammemberad.TeamMemberRole = 'Customer Success Manager';
ATM.add(Teammemberad);

if(!ATM.isEmpty()){
insert ATM;
insert ashareLIST;
}
}
}
}
}

public class UpdateCSM{        
    public static void updateTeamMember(List<Account> accounts){            
        List<AccountShare> ashareLIST = new List<AccountShare>();            
        List<AccountTeamMember> ATM = new List<AccountTeamMember>();            
        Set<String> rmMember = new Set<String>();            
        Map<ID, ID> acctToBRepMap = new Map<ID, ID>();            
    
        for(Account a:accounts){   
                     
            AccountShare caSharingRule = new AccountShare();                   
            caSharingRule.AccountId = a.Id;                   
            caSharingRule.OpportunityAccessLevel = 'Edit';                   
            caSharingRule.CaseAccessLevel = 'Edit';                   
            caSharingRule.AccountAccessLevel = 'Edit';                   
            caSharingRule.UserOrGroupId = a.Customer_Success_Manager__c;                   
            ashareLIST.add(caSharingRule);                       
        
            if(a.Customer_Success_Manager__c!= null){                 
                AccountTeamMember Teammemberad=new AccountTeamMember();
                Teammemberad.AccountId=a.id;
                Teammemberad.UserId=a.Customer_Success_Manager__c;
                Teammemberad.TeamMemberRole = 'Customer Success Manager';                  
                ATM.add(Teammemberad);          
    
                  if(!ATM.isEmpty()){              
                      insert ATM;                          
                      insert ashareLIST;                                 
                  }               
            }                
        }                
    }              
}
Source Link
Loading