You need to sign in to do that
Don't have an account?
Shrey Tyagi
Unable to add values to Map<Id,List<Id>> -Please help!!!
Hi ,
I have this code below. I need to add values to Map<Id,List<Id>>, it is giving an error , can anyone pleas ehelp?
trigger Project_Risk_Review_Trigger on Project_Risk_Review__c (after insert,after update) {
// Create a new list of sharing objects for Project_Risk_Review
List<Project_Risk_Review__Share> ProjectRiskReviewShrs = new List<Project_Risk_Review__Share>();
Map<Id,List<Id>> OldSharesMap=new Map<Id,List<Id>>();
// Declare variables for super user sharing.
Project_Risk_Review__Share SuperUserShrDvp;
Project_Risk_Review__Share SuperUserShrDelegate;
Project_Risk_Review__Share SuperUserShrProjectDirector;
Project_Risk_Review__Share SuperUserShrChairReviewer;
for(Project_Risk_Review__c NewAssessment : trigger.new){
Project_Risk_Review__c oldReview = Trigger.oldMap.get(NewAssessment.ID);
if(NewAssessment.DVP__c != Null && ((Trigger.IsInsert && Trigger.IsAfter)||(Trigger.IsUpdate && Trigger.IsAfter && (NewAssessment.DVP__c !=oldReview.DVP__c)))){
// Instantiate the sharing objects
SuperUserShrDvp = new Project_Risk_Review__Share();
// Set the ID of record being shared
SuperUserShrDvp.ParentId = NewAssessment.Id;
// Set the ID of user or group being granted access
SuperUserShrDvp.UserOrGroupId =NewAssessment.DVP__c;
SuperUserShrDvp.AccessLevel = 'edit';
// Set the Apex sharing reason for DVP
SuperUserShrDvp.RowCause = Schema.Project_Risk_Review__Share.RowCause.PRAS_Super_Users_R_W_Access__c;
// Add objects to list for insert
ProjectRiskReviewShrs.add(SuperUserShrDvp);
if(Trigger.IsAfter && Trigger.IsUpdate){
OldSharesMap.put(oldReview.ID,oldReview.DVP__c);
}
}
I have this code below. I need to add values to Map<Id,List<Id>>, it is giving an error , can anyone pleas ehelp?
trigger Project_Risk_Review_Trigger on Project_Risk_Review__c (after insert,after update) {
// Create a new list of sharing objects for Project_Risk_Review
List<Project_Risk_Review__Share> ProjectRiskReviewShrs = new List<Project_Risk_Review__Share>();
Map<Id,List<Id>> OldSharesMap=new Map<Id,List<Id>>();
// Declare variables for super user sharing.
Project_Risk_Review__Share SuperUserShrDvp;
Project_Risk_Review__Share SuperUserShrDelegate;
Project_Risk_Review__Share SuperUserShrProjectDirector;
Project_Risk_Review__Share SuperUserShrChairReviewer;
for(Project_Risk_Review__c NewAssessment : trigger.new){
Project_Risk_Review__c oldReview = Trigger.oldMap.get(NewAssessment.ID);
if(NewAssessment.DVP__c != Null && ((Trigger.IsInsert && Trigger.IsAfter)||(Trigger.IsUpdate && Trigger.IsAfter && (NewAssessment.DVP__c !=oldReview.DVP__c)))){
// Instantiate the sharing objects
SuperUserShrDvp = new Project_Risk_Review__Share();
// Set the ID of record being shared
SuperUserShrDvp.ParentId = NewAssessment.Id;
// Set the ID of user or group being granted access
SuperUserShrDvp.UserOrGroupId =NewAssessment.DVP__c;
SuperUserShrDvp.AccessLevel = 'edit';
// Set the Apex sharing reason for DVP
SuperUserShrDvp.RowCause = Schema.Project_Risk_Review__Share.RowCause.PRAS_Super_Users_R_W_Access__c;
// Add objects to list for insert
ProjectRiskReviewShrs.add(SuperUserShrDvp);
if(Trigger.IsAfter && Trigger.IsUpdate){
OldSharesMap.put(oldReview.ID,oldReview.DVP__c);
}
}
Let us know if this will help you