- There are 2 custom objects involved.
- Project__c is the parent, Project_Contact__c is the child.
- Both objects contain a field called Survey_Sent__c.
- Whenever 'Survey Sent' is updated on the child, I'd like my trigger to fire and update 'Survey Sent' on the parent.
============ Code so Far =========
trigger UpdateProjectSurveySent on Project_Contact__c (before update) {
if(trigger.isUpdate){ // if trigger fired due to an update
List<Id> parentIds = new List<id>(); // create a list variable to that holds Ids
List<Id> childIds = new List<Id>(); // list to hold child Ids
for(Project_Contact__c Pc : trigger.new){ // cycle through child records, grab Ids, store child Ids in trigger.new
parentIds.add(Pc.Project__c.Id); // then add parent Ids to our parent Id list. Lists are ordered. This is kind of a map stucture.
childIds.add(Project_Contact__c.Id);
}
List<Project__c> pj = [SELECT Id, Survey_Sent__c FROM Project__c WHERE Id in: parentIds]; // fill list3 with projects that have an Id stored in pjIdList
for(Project__c p : pj){ // cycle list3 projects, and make Survey Sent fields match.
p.survey_sent__c = pj.survey_sent__c;
}
}
}
Survey_Sent__c
values?