You need to sign in to do that
Don't have an account?

Trigger to Update Custom Field on Account after an Event Date/Time Passes
Hi,
I'm trying to figure out how to write a trigger that will update a custom field (Stage_c) with a particular pick-list value after an Event date and time passes.
Basically in the Event Subject field, I have a picklist value called "Needs Assessment", what I need to accomplish is...if an Event has the subject of "Needs Assessment" and the date and time passes i.e., "Completed" and this Event now falls under Activity History, I need to have the custom field (Stage_c) update to a picklist value "Needs Assessment Completed".
I have triggers working great for the same process on Tasks, but since Events are not "Completed" per se, how do I go about writing a trigger for this same action but on events? Is it possible?
Below is the code I currently use on my Task trigger:
trigger changeAccountStagetask3 on Task (before update, after update) {
List<Account> accsToUpdate = new List<Account>();
for (Task tsk: Trigger.new){
if(tsk.Status=='Completed' && tsk.Subject=='Initial Sell/Needs Assessment'){
Account ld = new Account(Id=tsk.whatid);
ld.Stage__c = 'Needs Assessment Completed';
accsToUpdate.add(ld);
}
}
update accsToUpdate;
}
Any help would be wonderful!!!
Thanks!!!
I'm trying to figure out how to write a trigger that will update a custom field (Stage_c) with a particular pick-list value after an Event date and time passes.
Basically in the Event Subject field, I have a picklist value called "Needs Assessment", what I need to accomplish is...if an Event has the subject of "Needs Assessment" and the date and time passes i.e., "Completed" and this Event now falls under Activity History, I need to have the custom field (Stage_c) update to a picklist value "Needs Assessment Completed".
I have triggers working great for the same process on Tasks, but since Events are not "Completed" per se, how do I go about writing a trigger for this same action but on events? Is it possible?
Below is the code I currently use on my Task trigger:
trigger changeAccountStagetask3 on Task (before update, after update) {
List<Account> accsToUpdate = new List<Account>();
for (Task tsk: Trigger.new){
if(tsk.Status=='Completed' && tsk.Subject=='Initial Sell/Needs Assessment'){
Account ld = new Account(Id=tsk.whatid);
ld.Stage__c = 'Needs Assessment Completed';
accsToUpdate.add(ld);
}
}
update accsToUpdate;
}
Any help would be wonderful!!!
Thanks!!!

Use a time dependent workflow which will update some flag fire your trigger when the field is changed