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; } }
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.
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.
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?
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.
All Answers
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?