You need to sign in to do that
Don't have an account?
trigger problem 2
trigger updaterecord on Account (before insert){
for(Account acc: trigger.new){
Account acc1;
acc1.Type= 'prospecting';
update acc1;
}
}
its give error when m going to insert..
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger updaterecord caused an unexpected exception, contact your administrator: updaterecord: execution of BeforeInsert caused by: System.SObjectException: DML statment cannot operate on trigger.new or trigger.old: Trigger.updaterecord: line 7, column 1
for(Account acc: trigger.new){
Account acc1;
acc1.Type= 'prospecting';
update acc1;
}
}
its give error when m going to insert..
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger updaterecord caused an unexpected exception, contact your administrator: updaterecord: execution of BeforeInsert caused by: System.SObjectException: DML statment cannot operate on trigger.new or trigger.old: Trigger.updaterecord: line 7, column 1
You are trying to update an Account which is not inserted yet. Try below code
Let me know if it helps you.
Regards
Amrender