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
dinesh jaindinesh jain 

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