 • John Murphy 38
• NEWBIE
• 10 Points
• Member since 2018

• Chatter
Feed
• 0
• 0
• 0
Likes Given
• 1
Questions
• 5
Replies
I need to generate a project task list with due dates for each task  The due dates are calcualted b taking the total # of days for the project and dividing by the number of tasks, so for a 90 day project with 3 tasks, each task would be 30 days apart, with teh first occuring 30 days after the project start date.  The follwing code gives me the tasks, but each task has the same due date -Start_date +30 days.  So I have something wrong in the For loop, but cna't figure out what it is.  Can someone help?

trigger tasks on Project__c (after insert)

for (Project__c proj : Trigger.New) {
Date DueDate = proj.Start_Date__c+30;
Date nextDueDate = DueDate;

for (Integer i = 0; i < proj.Number_of_Tasks__c; i++)

{

Subject ='Project Task - '+ (i+1),
Status = 'In progress',
Priority = 'High',
ActivityDate =  nextDueDate,
WhatId = proj.id
));
}

}
}
• • July 27, 2018
• Like
• 0
I need to generate a project task list with due dates for each task  The due dates are calcualted b taking the total # of days for the project and dividing by the number of tasks, so for a 90 day project with 3 tasks, each task would be 30 days apart, with teh first occuring 30 days after the project start date.  The follwing code gives me the tasks, but each task has the same due date -Start_date +30 days.  So I have something wrong in the For loop, but cna't figure out what it is.  Can someone help?

trigger tasks on Project__c (after insert)

for (Project__c proj : Trigger.New) {
Date DueDate = proj.Start_Date__c+30;
Date nextDueDate = DueDate;

for (Integer i = 0; i < proj.Number_of_Tasks__c; i++)

{

Subject ='Project Task - '+ (i+1),
Status = 'In progress',
Priority = 'High',
ActivityDate =  nextDueDate,
WhatId = proj.id
));
}

}
}
• • July 27, 2018
• Like
• 0
Hi,
Though i have coded the with the same specification as asked in the challenge but then also challenge failing.
Not sure why this is happening. The issue is actually the code or Trailhead is not working fine.

I am a beginner so facing issue in identifying it.
Need help.

• 