• dsprashanth
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

Hi , I have a below trigger (no compilation Error) .It gives  System.FinalException: SObject row does not allow errors .

 

trigger trigrnotes on Note (before update) {

if(trigger.IsBefore){

List <TriggerOnNotesObject__c> tt =[Select Id , Is_Closed__c from TriggerOnNotesObject__c where Is_Closed__c=True ] ;
List<Note> Ntes = [Select Id , ParentId from Note where ParentId IN : tt ] ;

for (TriggerOnNotesObject__c CstObj : tt ){
if(CstObj .Is_Closed__c) {

for(Note n :Ntes )
CstObj.addError('test');

}
}

}
}

 

Alternatively , i have used (it is working fine but not according to my requirement , atleast it is showing error message )

 

for (TriggerOnNotesObject__c CstObj : tt ){
if(CstObj .Is_Closed__c) {

for(Note n :Trigger.new )

n.addError('test');

 

 

My requirement is to restrict users from editing Notes for SOject whose field Is_closed is True (checked) .Please Guide me . 

 

Thanks .