function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Aryan JhaAryan Jha 

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;

}
VinayVinay (Salesforce Developers) 
Hi Aryan,

What is the error do you see? 

Thanks,