+ Start a Discussion
WikWik 

Error in the code

Hi,

 

trigger UnAssignServiceAgreement on Equipment__c (after update) {

Set<id> equipids = new Set<id>();    

for (Equipment__c equipment : Trigger.new) {     

    if (equipment.Job_Number__c == null && equipment.Job_Number__c != trigger.oldMap.get(equipment.id).Job_Number__c) {     

    equipids.add(equipment.id);      

       equipment.Under_Contract__c = False;   

          equipment.Contract_Status__c = 'Not Under Contract';         }     } }

 

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger UnAssignServiceAgreement caused an unexpected exception, contact your administrator: UnAssignServiceAgreement: execution of AfterUpdate caused by: System.FinalException: Record is read-only: Trigger.UnAssignServiceAgreement: line 8, column 1

Force TechieForce Techie

Hi Wik,

 

In your trigger code you are not updating "Equipment" records after assignments values to fields. So, please update your records with DML operation "update Trigger.new;". Because on event type of After you have to perform DML operation statement in your code.

 

Thanks!