function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SudhanwaSudhanwa 

Trigger on note for before delete/update

Hi,

 

 Can someone help me out on this 

 

 

trigger EditDeleteOnNotes on Note (before delete, before update)
{

 for (note NewNote :trigger.old)
 {

  if(trigger.isDelete)
  {
   NewNote.addError('Invalid operation. delete operation is not allowed on note object.');
  }
 }
  for (note NewNote :trigger.new)
 {
  if(trigger.isUpdate)
  {
   NewNote.addError('Invalid operation. edit operation is not allowed on note object.');
  }
 }
 }

 

Error:

 

EditDeleteOnNotes: execution of BeforeDelete

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.EditDeleteOnNotes: line 18, column 22