I'm attempting to create a trigger that fires when my custom field "Retreat Role", on a campaign member becomes "Prospect". Now when they become a prospect I want to create a task for the user, that reminds them to create a follow up after 5 days from the day the trigger is fired. I have found a similar trigger to what I am looking for, but I am by no means much of a coder. Now I'm not completely sure how to make it so that the due date (ActivityDate) on my Task is presented as 5 days after the date that my trigger fires. I was wondering if anyone could help me with this.
trigger InsertCompletedCallTask on CampaignMember (BEFORE update) {
list<Task> AddTask = new List<Task>();
for (CampaignMember CM : Trigger.new) {
if (cm.Retreat_Role__c == 'Prospect') {
system.debug(cm + '---------AddTask---------' + CM.Campaign);
AddTask.add(new Task(
Subject = 'Follow up with Prospect',
ActivityDate = date.today + 5,
WhoId = CM.Contact.AccountId,
WhatId = CM.CampaignId));
}
}
insert AddTask;
}