I have written this trigger up update an field on the account if the field on any opportunity related to the account is checked. At first I had the check box being updated by a workflow but I thought that might be what was causing the problem. I turned off the workflow but still getting the same error. Any help?
Error:Apex trigger OpportunityUpdateAccount caused an unexpected exception, contact your administrator: OpportunityUpdateAccount: execution of AfterUpdate caused by: System.FinalException: Record is read-only: Trigger.OpportunityUpdateAccount: line 5, column 1
trigger OpportunityUpdateAccount on Opportunity( after insert, after update ) {
List<Account> accsToUpdate = new List<Account>();
for(Opportunity opp : trigger.new){
if (opp.Opportunity_Order_Status__c = true )
accsToUpdate.add(new Account(Id = opp.Account.Id, ACCOpportunity_Order_Status__c = 'true'));
}
if (accsToUpdate != null && !accsToUpdate.isEmpty())
Database.update(accsToUpdate);
}