I have a custom object called Location__c that has a date field called Active_Date__c. Location__c has a child object called Cans__c. Cans__c has a date field Start_Date__c. I would like to write a trigger that populates the child dates with the master date. I am very new to this, so be gentle. Here is what I have so far:
trigger addActiveDateToChildStartDate on Location__c(after insert, after update){
Can__c[] canList = new can__c[0];
Map <Id,Can__c> servicesMap = new Map<id,Can__c>();
locations.putAll([SELECT Id,Active_Date__c,(SELECT Id, Start_Date__c FROM Cans__r)FROM Location__c WHERE Id In :locations.keySet()]);
for (Location__c Loc: locations){
List<Can__c> services = Loc.getSObjects('Can__c');
servicesMap.put(Loc.Id, Can__c);
}
}
Any help would be appriciated, Thanks!