You need to sign in to do that
Don't have an account?
Deepanshu Kochar
Error while creating "Add a task" trigger on opportunity
Hi All , i created trigger on Opportunity to add a follow up task whenever a new opportunity is created with "StageName = Closed Won". --->
trigger ClosedOpportunityTrigger on Opportunity (after insert , after update) {
list<task> listtask = new list<task>();
for (opportunity opp : trigger.new){
if (opp.StageName == 'Closed Won'){
task NewTask = new task();
task.subject = 'Follow Up Test Task';
task.ActivityDate = system.today().addmonths(1);
task.whatid = opp.Id;
listtask.add(NewTask);
}
}
if (listtask.size()>0)
insert listtask;
}
How ever while saving the trigger i get an error : Error: Compile Error: Expression cannot be assigned at line -1 column -1
Can not seem to move past this , please help also point out if you see any rookie mistakes in the trigger code.
Thanks
trigger ClosedOpportunityTrigger on Opportunity (after insert , after update) {
list<task> listtask = new list<task>();
for (opportunity opp : trigger.new){
if (opp.StageName == 'Closed Won'){
task NewTask = new task();
task.subject = 'Follow Up Test Task';
task.ActivityDate = system.today().addmonths(1);
task.whatid = opp.Id;
listtask.add(NewTask);
}
}
if (listtask.size()>0)
insert listtask;
}
How ever while saving the trigger i get an error : Error: Compile Error: Expression cannot be assigned at line -1 column -1
Can not seem to move past this , please help also point out if you see any rookie mistakes in the trigger code.
Thanks
Hi Deepanshu,
Use this code, It will help you :)
Thanks
Rajat Maheshwari
rajatzmaheshwari@gmail.com
All Answers
Hi Deepanshu,
Use this code, It will help you :)
Thanks
Rajat Maheshwari
rajatzmaheshwari@gmail.com
Thanks'
Thanks
Rajat maheshwari
rajatzmaheshwari@gmail.com