Record is read-only error in Salesforce Apex Trigger

Record is read-only error in Salesforce Apex Trigger

Exception:

System.FinalException: Record is read-only

Field update cannot be done after the record has been Inserted/Updated/Saved. So, use after insert or after update as the trigger events.

Sample Trigger to reproduce the issue:

trigger AccountTrigger on Account ( after insert ) {
    
    for ( Account objAcc : trigger.new ) {
        
        objAcc.Description = 'Testing';
        
    }

}

“System.FinalException: Record is read-only” Salesforce Exception is thrown since the Account trigger is updating the Description field value of the Account record in “after insert” event.

Leave a Reply