You need to sign in to do that
Don't have an account?

Read-only when After Insert while updating the fields of the trigger.new
The following trigger gives me this error:
Apex trigger LineItemTest caused an unexpected exception, contact your administrator: LineItemTest: execution of AfterInsert caused by: System.Exception: Record is read-only: Trigger.LineItemTest: line 3, column 9
=============================
trigger LineItemTest on OpportunityLineItem (after insert) {
for(OpportunityLineItem li: trigger.new) {
li.Description = 'This is the replacement';
}
}



Solved my own problem. The tigger needs to be BEFORE INSERT.