+ Start a Discussion
Jessica HousemanJessica Houseman 

Update Child Record date from change on Parent Record Date

I am using the application "Milestones PM" and when the project start date is updated on the Parent record I need the child records (milstones, tasks) dates to update accordingly. 

Example: Project start date changed to 4/9/2011 and Task #1's due date equals (Project Start date + 3) how can I get this to filter down?

Workflow obviously does not work or filter down so I guess I need a trigger but I do not know where to start...  

Hi Jessica,

Below is the sample code that I tested for a sample custom object 'travel__c'. Travel__c has a date field with the name 'Start_date__c'. The below trigger updates the related tasks(if any) due dates for the corresponding travel record by 3 days after an update event on Travel__c;

trigger traveltaskcreateupdate on travel__c (after update) {
    set<id> ids=new set<id>();
    for(travel__c travel:trigger.new){
    list<task> taskstoupdate=new list<task>();
   List<task> task1=new List<task>([select id,activitydate,whatid from task where whatid=:ids]);
   map<id,travel__c> travelmap=new map<id,travel__C>([select id,start_date__c from travel__c where id=:ids]);
    for(task task2:task1){
    update taskstoupdate;

In the above code I did not add the logic to process the trigger only when the start date is changed which you can do by following the guidelines as per the below post

Hope this helps!!