We created an opportunity and expected it to have an associated task, but it didn’t. Make sure your trigger inserts the task into the database
2 3 4 5 6 7 8 9 10 11 12 13 14 15 trigger ClosedOpportunityTrigger on Opportunity (after insert,after update) { List taskListToInsert = new List();
for(Opportunity opp : [Select Id,StageName from Opportunity
where Id in :Trigger.New AND StageName = 'Closed Won'])
{
taskListtoInsert.add(new Task(Subject ='Follow Up Test Task',WhatId = opp.Id));
}
if(taskListtoInsert.size()>0)
{
insert taskListtoInsert;
}
}
Instead this line
try this
You should also check if you have any process builder activated that may be causing this problem