You need to sign in to do that
Don't have an account?
Angela Schloeder
Trigger on Contact to create Task when field value is changed.
I'm trying to create a trigger to create a task everytime the field 'Call Results' is changed. This is what I have, but doesn't work. I am not a developer by any means. Copied this from another trigger and trying to make it work.
trigger NewCreateTask on Contact (after insert, after update) {
List<Task> listOfTaskToBeInserted = new List<Task>();
Task newtask;
if(trigger.isInsert){
for(Contact con : trigger.new){
if(con.Call_Result__c == 'N/A' || con.Call_Result__c == 'Requested More Info' || con.Call_Result__c == 'Left voicemail' || con.Call_Result__c == 'No Answer or VM' || con.Call_Result__c == 'Not Interested' || con.Call_Result__c == 'Wants Call Back' || con.Call_Result__c == 'Set Meeting'){
newtask = new Task();
newtask.WhatId = con.AccountId;
newtask.Subject = 'Task';
newtask.whoId = con.id;
newtask.ActivityDate = system.today();
newTask.Status = 'Completed';
{
listOfTaskToBeInserted.add(newTask);
}
}
}
}
if(listOfTaskToBeInserted.size() > 0){
upsert listOfTaskToBeInserted;
}
}
trigger NewCreateTask on Contact (after insert, after update) {
List<Task> listOfTaskToBeInserted = new List<Task>();
Task newtask;
if(trigger.isInsert){
for(Contact con : trigger.new){
if(con.Call_Result__c == 'N/A' || con.Call_Result__c == 'Requested More Info' || con.Call_Result__c == 'Left voicemail' || con.Call_Result__c == 'No Answer or VM' || con.Call_Result__c == 'Not Interested' || con.Call_Result__c == 'Wants Call Back' || con.Call_Result__c == 'Set Meeting'){
newtask = new Task();
newtask.WhatId = con.AccountId;
newtask.Subject = 'Task';
newtask.whoId = con.id;
newtask.ActivityDate = system.today();
newTask.Status = 'Completed';
{
listOfTaskToBeInserted.add(newTask);
}
}
}
}
if(listOfTaskToBeInserted.size() > 0){
upsert listOfTaskToBeInserted;
}
}
Best Answer chosen by Angela Schloeder
Raj Vakati