Apex Sharing for Standard Case Object . For every Standard Object we need to append Share keyword. Like for case apex sharing object will be CaseShare
List<Case> CasesList = [SELECT ID FROM Case]; List<CaseShare> csShareList = new List<caseShare>(); for(Case csInstance:CasesList){ for(User usrInstance:[Select ID FROM USER WHERE IsActive = TRUE AND ProfileId ='00e5C000000DeBi']){ CaseShare csShare = new CaseShare();//this should be in for loop csShare.CaseId =csInstance.Id; csShare.UserOrGroupId = usrInstance.Id; csShare.CaseAccessLevel = 'edit'; csShareList.add(csShare); } } Insert csShareList;
No comments:
Post a Comment