public class projectteamhandler {
public static void isProjectteam(List<Projectteam__c>newList){
List<Project__share> projectshares=new List<Project__share>();
for(Projectteam__c proj:newList){
Project__share projRecord=new Project__share();
projRecord.ParentId=proj.Related_Project__c;
projRecord.UserOrGroupId =proj.Team_member__c;
projRecord.AccessLevel = 'read';
projRecord.RowCause = 'Manual';
projectshares.add(projRecord);
}
insert projectshares;
}
public static void isProjectteamdelete(List<Projectteam__c>oldList){
System.debug('oldList'+oldList);
List<Id>proId=new List<Id>();
for(Projectteam__c pro:oldList){
proId.add(pro.ID);
}
System.debug('proId'+proId);
List<Projectteam__share> proj=[Select Id From Projectteam__share where parentId In: proId];
System.debug('proj'+proj);
LIst<Id>projID=new LIst<Id>();
for(Projectteam__share p:proj){
projID.add(p.Id);
}
System.debug('projID'+projID);
List <Project__share> projshare=[Select id,ParentId,UserOrGroupId From Project__share where ParentId In :projID];
System.debug('projshare'+projshare);
}
} public static void isProjectteamdelete(List<Projectteam__c>oldList){ System.debug('oldList'+oldList); ListproId=new List(); for(Projectteam__c pro:oldList){ proId.add(pro.ID); } System.debug('proId'+proId); List<Projectteam__share> proj=[Select Id From Projectteam__share where parentId In: proId]; System.debug('proj'+proj); LIstprojID=new LIst(); for(Projectteam__share p:proj){ projID.add(p.Id); } System.debug('projID'+projID); List <Project__share> projshare=[Select id,ParentId,UserOrGroupId From Project__share where ParentId In :projID]; System.debug('projshare'+projshare); }