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

Executing against the trigger does not work as expected.
trigger ClosedOpportunityTrigger on Opportunity (After insert,After update) {
List<Task>taskofopportunity=new List<Task>();
for(Opportunity opp:Trigger.new)
{
if(opp.StageName=='Closed_won')
{
Task t=new Task();
t.WhatId=opp.Id;
t.Subject='Follow Up Test Task';
taskofopportunity.add(t);
}
}
insert taskofopportunity;
}
List<Task>taskofopportunity=new List<Task>();
for(Opportunity opp:Trigger.new)
{
if(opp.StageName=='Closed_won')
{
Task t=new Task();
t.WhatId=opp.Id;
t.Subject='Follow Up Test Task';
taskofopportunity.add(t);
}
}
insert taskofopportunity;
}
What is the error do you see?
Thanks,