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
ifthikar Ahmed 1ifthikar Ahmed 1 

trigger.old clarification

can we use trigger.old in after insert event ???

More over, my code is to create a new invoice record when the "active checbox" is selected true in the coustomer obj and the old value shuld be unchecked. event has to update evvent where in my trigger works fine in  after Insert how come pls explain

trigger test1 on Apex_Customer__c (after Insert) {
   list <APEX_Invoice__c> upinv = new list <APEX_Invoice__c>();
   for(Apex_Customer__c newcus :
       if(newcus.APEX_Active__c == True && trigger.oldmap.get( != True )
           APEX_Invoice__c newinv = new APEX_Invoice__c();
           newinv.APEX_Customer__c = newcus.Id;
insert upinv;
Dhanya NDhanya N

We can not use trigger.old in after insert event. It returns null as there is no old instance.
Take a look on trigger context variable (