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
Lauren_HLauren_H 

Trigger error read only

I have seen a couple of these posts, but I'm still confused how to get my trigger to work. Here is my error:

 
OnPropLIUpdateIICopyFormulaValueToManual: execution of AfterInsert caused by: System.FinalException: Record is read-only Trigger.OnPropLIUpdateIICopyFormulaValueToManual: line 7, column 1
 
This is my trigger... any ideas??
 
trigger OnPropLIUpdateCopyFormulaValueToManual on Apttus_Proposal__Proposal_Line_Item__c (after update, after insert) {

 if (trigger.new.size()<>1) 
    return;
    //decimal installationTechServicesTotal = 0;
            if (trigger.new[0].Installation_Technical_Services__c != trigger.new[0].Installation_Tech_Ser_Formula__c){
              trigger.new[0].Installation_Technical_Services__c = trigger.new[0].Installation_Tech_Ser_Formula__c;
            }
    
}
Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox
Use "before update" and "before insert". Note that formulas may not work in a before DML event, so you might have to come up with another means of determining which tech you intend to assign, but try that first and get back to us.

All Answers

sfdcfoxsfdcfox
Use "before update" and "before insert". Note that formulas may not work in a before DML event, so you might have to come up with another means of determining which tech you intend to assign, but try that first and get back to us.
This was selected as the best answer
Lauren_HLauren_H

That did the trick. I am confused, as I am running another trigger that does that same thing, it just updates some different fields, and that does not give me an error. Any idea why?

sfdcfoxsfdcfox
It's surely not updating anything in Trigger.new, because that's not allowed. The data is already committed to the database and is unchangeable. Look closer, and you'll see that those triggers are either updating related records, or are actually before DML events.