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
DritterDritter 

FATAL_ERROR|System.FinalException: Record is read-only


When I add order.Paid__c = true to the trigger below, I get a Fatal Error. Can someone explain why and the best way to handle this issue? I'm trying to generate a new object for paid orders we take from the website. All of the amount fields are summary rollups or formulas, so I can use them. 

trigger TermsandConditionsFutureMP on ccrz__E_Order__c (after update) {
   System.debug('TC Start execution of trigger');
   
   if(trigger.isAfter){ 
   
   String myString1 = 'Website';
   
       for (ccrz__E_Order__c order:trigger.new){
           ccrz__E_Order__c orderUpdate = System.Trigger.oldMap.get(order.id);
           if (order.Paid__c = true && orderUpdate.origin1__c != order.origin1__c){
               if (myString1.equalsIgnoreCase(order.Origin1__c)){
                  System.debug('TC trigger is after');
                  TermsandConditionsFutureMP.createTermsandConditionsMP (Trigger.newMap.keySet());
               }
           }
       }
   }
   System.debug('TC trigger has been executed');
}
Best Answer chosen by Dritter
BalajiRanganathanBalajiRanganathan
you  have to use == to check for equals. also for boolean you can directly use the variable

change

 if (order.Paid__c = true && orderUpdate.origin1__c != order.origin1__c){

to 

 if (order.Paid__c && orderUpdate.origin1__c != order.origin1__c){