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;
}
}
}
}
}