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

Newbie to Triggers - need HELP
Hi Everyone,
I'm just getting started on how to use triggers...I'm trying to write a trigger that will update a custom field (Stage_c) to a specific picklist value (Actively Working) on my Lead Detail page based on an Activity Task Type - Call to Qualify (Unsuccessful) - when the Activity has been completed.
I came across this post - https://developer.salesforce.com/forums/ForumsMain?id=906F00000008mcOIAQ - and tried tweaking it a bit to work for this requirement, but I keep getting errors.
ANY assistance would be greatly appreciated!!!
Thank you in advance for your help!!!
I'm just getting started on how to use triggers...I'm trying to write a trigger that will update a custom field (Stage_c) to a specific picklist value (Actively Working) on my Lead Detail page based on an Activity Task Type - Call to Qualify (Unsuccessful) - when the Activity has been completed.
I came across this post - https://developer.salesforce.com/forums/ForumsMain?id=906F00000008mcOIAQ - and tried tweaking it a bit to work for this requirement, but I keep getting errors.
ANY assistance would be greatly appreciated!!!
Thank you in advance for your help!!!
All Answers
if it solved you question please mark as solved :)
trigger changeAccountStagetask1 on Task (before insert, before update) {
List<Account> accsToUpdate = new List<Account>();
for (Task tsk: Trigger.new){
if(tsk.Status=='Completed' && tsk.Subject=='Set 1st Appointment'){
Account ld = new Account(Id=tsk.whoid);
ld.Stage__c = 'Need To Set Meeting';
accsToUpdate.add(ld);
}
}
update accsToUpdate;
}
Error:
Apex trigger changeAccountStagetask1 caused an unexpected exception, contact your administrator: changeAccountStagetask1: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []: Trigger.changeAccountStagetask1: line 11, column 1
Any thoughts? I'm sure I'm way off in my code...ugh!!!
Thank you in advance!!! :)