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; } }
You can use an object to change its own field values usingtrigger.new, but only in before triggers. In all after triggers,trigger.newis not saved, so a runtime exception is thrown.
So you cannot modify a record which in trigger.new context in case of after triggres (your record will be read only)
If you want to update same record you can try with before trigger where your record will not be read only.
You can use an object to change its own field values usingtrigger.new, but only in before triggers. In all after triggers,trigger.newis not saved, so a runtime exception is thrown.
So you cannot modify a record which in trigger.new context in case of after triggres (your record will be read only)
If you want to update same record you can try with before trigger where your record will not be read only.
So you cannot modify a record which in trigger.new context in case of after triggres (your record will be read only)
If you want to update same record you can try with before trigger where your record will not be read only.
Hit kudos if this post helps you
All Answers
From the trigger docs:
Note that this sObject list is only available in insert and update triggers, and the records can only be modified in before triggers.
http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#CSHID=apex_triggers_context_variables.htm|StartTopic=Content%2Fapex_triggers_context_variables.htm|SkinName=webhelp
So you cannot modify a record which in trigger.new context in case of after triggres (your record will be read only)
If you want to update same record you can try with before trigger where your record will not be read only.
Hit kudos if this post helps you
I changed it to a before trigger and it worked. Thank you!