Skip to main content

Posts

Showing posts with the label Exception: SObject row does not allow errors

Exception: SObject row does not allow errors

There is a lot of things which salesforce do Out Of Box(OOB) but we do code some time, Sometimes triggers are used and some time we do use helper class. While dealing with apex code we do see some exceptions so today we will discuss about a specific error which is System.FinalException: SObject row does not allow errors. When: While using addError method with retrieved record from database. Example: List<Account> accList = [SELECT Id,Name                               FROM Account                               WHERE Id IN :Trigger.old];//Retrived data from Database     for(Account acc : accList){          if(acc.Name == 'Non Working Code'){              acc.addError('Exception:System.FinalException: SObject row does not allow');//will through exception          }       } Solution: for(Account acc : Trigger.new){         if(acc.Name == 'Working Code'){             acc.addError('This add error working fine.');         }     }

Translate