trigger ClosedOpportunityTrigger on Opportunity (before insert, before update) {
List<Task> listTask = new List<Task>();
for(Opportunity opp : Trigger.New){
if(opp.StageName=='Closed Won'){
Task t= new Task();
t.subject = 'Follow Up Test Task';
t.WhatId = opp.Id;
listTask.add(t);
}
}
insert listTask;
}
更多推荐
Create an Apex trigger for Opportunity that adds a task to any opportunity set t
发布评论