You need to sign in to do that
Don't have an account?
![dbruns dbruns](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Newbie Code Issue - Prevent Delete of a Closed Won Opportunity
Hello,
I wrote the following trigger to prevent deletion of a Closed Won Opportunity:
trigger CannotDeleteClosedWon on Opportunity (before delete)
{
if(system.Trigger.isDelete)
{
for (Opportunity Opps : trigger.new)
if (Opps.StageName == 'Closed Won')
{
Opps.addError('Cannot delete a Closed Won Opportunity');
}
}
}
The problem, I keep getting sent to a page with the following message:
CannotDeleteClosedWon: execution of BeforeDelete
caused by: System.NullPointerException: Attempt to de-reference a null object
Trigger.CannotDeleteClosedWon: line 5, column 29
Any suggestions?
All Answers
geting this error
unexpected syntax: 'mismatched input '<EOF>' expecting RCURLY'