Skip to content

Instantly share code, notes, and snippets.

@mkorman
Last active March 14, 2016 17:31
Show Gist options
  • Save mkorman/041913128f417bc91848 to your computer and use it in GitHub Desktop.
Save mkorman/041913128f417bc91848 to your computer and use it in GitHub Desktop.
trigger CreateFollowupTask on Lead (after insert, after update) {
List <Task> followupTasks = new List <Task> ();
for (Lead newLead : trigger.new)
{
if (newLead.isConverted) continue;
if (newLead.Status == 'Open - Not Contacted') {
Task newTask = new Task ( Subject = 'Intial call', Type = 'Call', ActivityDate = Date.Today().AddDays(2),
Status = 'Not Started', whoId = newLead.Id);
followupTasks.Add (newTask);
}
else if (newLead.Status == 'Working - Contacted') {
Task newTask = new Task ( Subject = 'Send email', Type = 'Email', ActivityDate = Date.Today().AddDays(7),
Status = 'Not Started', whoId = newLead.Id);
followupTasks.Add (newTask);
}
}
insert followupTasks;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment