Reply
Contributor
dinesh jain
Posts: 5
0

execution of BeforeUpdate caused by: System.FinalException: SObject row does not allow

trigger restrictHindiTeacher on Contact (before Insert, before Update) {
    List<Contact> conNewList = trigger.new;
    List<Contact> conOldList = trigger.old;
   
        if(conNewList[0].subjects__c == 'hindi'){
            conNewList[0].addError('Teacher REstricted');        
        }else if(conOldList[0].subjects__c == 'hindi'){
            conOldList[0].addError('Teacher REstricted');        
        }
}

 

This code is working when I add subject hindi to picklist but doesn't work when remove hindi from piicklist.

Means is working while trigger.new but not while trigger.old