function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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!