trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {
List<Task> taskList = new List<Task>();
for(Opportunity opp : [SELECT Id, StageName FROM Opportunity WHERE StageName='Closed Won' AND Id IN : Trigger.New]){
taskList.add(new Task(Subject='Follow Up Test Task', WhatId = opp.Id));
}
if(taskList.size()>0){
insert tasklist;
}
}
WonderStudies
Error: The trigger closed opportunity trigger is using events in the before context .make sure to use after insert and update
Answer :- replace first line of your code with this " trigger ClosedOpportunityTrigger on Opportunity (after insert, after update)" and rest all is same you can take from pinned comment or code given above.
bullatriratna
Thank you so much! Your videos have been so useful
teacherana
Again one problem if is 7th line missing "at 'if'
Deepika_Dupakuntla
It's working. Just need to copy properly 😃
prajwalsahane
Error: We created an opportunity and expected it to have an associated task, but it didn’t. Make sure your Apex trigger inserts the task into the database.
Please help to solve this.
malaprolukrishnavamsi
I am facing this error "we tried to insert 200opportunities but apex trigger exceed DML limits.make sure your code is bulkifield" plz reply me
bhavanavaddepalli
We can’t find an Apex trigger named ‘ClosedOpportunityTrigger’.
Mine is showing while submitting
malayapati
It is showing that The Trigger " ClosedOpportunityTigger" is not a legal name . Pls kindly help me sirr....
kayathiniharika
the trigger closed opportunity trigger is using events in the before context plz help me
surisettishyamala
Its came like this Failed to enqueue tests an unknown exception occurred pls help me sir
madhu_drums_kadapa
duplicate value found: <unknown> duplicates value on record with id: <unknown>
how to solve this.
GowribhavaniBandila
The trigger ClosedOpportunityTrigger is using events in the 'before' context. Make sure to use after insert and after update. tell the answer i can't understand
pottidurga
Bro the process was consuming too much time After clicked on the CHECK CHALLENGE TO EARN 500 POINTS .
chinnachinnu
Trigger name, ClosedOpportunityTrigger, exists on different sObject type:Account
Will pls say answer to this prblm
lavanyaathina
getting this error .
pleasse anyone can help me with it?
We tried to insert Opportunity records as part of the challenge check, but the insert failed. Error: thException: OPP_INSERT | System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Discount_Percentage__c]: [Discount_Percentage__c]
RakeshSingh-zlzs
help me getting error first insert and update ani chupistuiodi
manju
Error:
The trigger closed opportunity trigger is using events in the before context .make sure to use after insert and update
thambamounika
Create a new playground it'll work .
laya
We can’t find an Apex trigger named ‘ClosedOpportunityTrigger’. help vro