trigger GudMorning on Class__c (before insert,after insert) {
        for(Class__c c1 : Trigger.new){
            c1.State__c = 'AP';
    } else {
        List<Class__c> crlst = new List<Class__c>();
            for(Class__c cr : Trigger.new){
                cr.State__c = 'TN' ;
                //insert cr;
  • 3
    If the truigger is ran after insert or update, you can no longer change the values in the Trigger.new map. So the line cr.State__c = 'TN'; is where you try to change a value in the Trigger.new map, which throws the error. I really don't see what your trigger is trying to achieve though, maybe you can update your question to elaborate on the goal. Apr 19, 2014 at 16:55

1 Answer 1


Change your trigger to before insert only (remove after insert) and it will work. The bit you have after insert should be done before.

Having said that, your trigger as written just doesn't make sense. What are you trying to do?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.