I want add a default task to an opportunity when this one is close won and the opportunity hasn't any task.
I get the error compiling the below code:
Entity 'Task' is not supported for semi join inner selects
trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {
List<Task> taskList = new List<Task>();
for (Opportunity opp : [Select Id, Name from Opportunity
Where Id IN :Trigger.New AND
Id NOT IN (Select WhatId from Task)]) {
// Add a default task for this Opportunity
If (opp.StageName == 'Closed Won') {
taskList.add(New Task(Subject ='Follow Up Test Task',
WhatId = opp.Id));
}
} //end for loop
}