title: Trigger to run only after checkbox goes rom unchecked to checked
body: <p>I want to run a trigger on Contact if a checkbox on Contact object goes from unchecked state to checked state and then do some processing on the records. I have this trigger on after insert and after update. The code works fine for update but if I check the box while creating a new contact record, the trigger does not detect the below condition in the code and therefore sends an empty list to contactTriggerHandler class.</p>
  <p>if (Trigger.oldMap.get(con.Id).checkbox==false  &amp;&amp; con.checkbox== true)</p>
  <pre><code>  trigger Contact on Contact (after update, after insert) {
  
  List&lt;Contact&gt; listofContacts = new List&lt;Contact&gt;();
  List&lt;Contact&gt; usersToCreate= new List&lt;Contact&gt;();
  if (Trigger.isAfter) {
  
      if(trigger.isInsert){
             System.debug('After insert');
             
             if(RecursiveTriggerHandler.isFirstTime){
                  RecursiveTriggerHandler.isFirstTime = false;
             for (Contact con : Trigger.new) {    
       
                Contact contacttoUpdate = con.clone(true,true);
                contacttoupdate.Nickname__c=contacttoUpdate.firstname;
                listofContacts.add(contacttoUpdate);  
                        
             }
  
             
                    
             System.debug(listofContacts);
             ContactTriggerHandler.AfterInsert(listofContacts);
             update listofContacts;
            }
         
        }
  
  
      else if(trigger.isUpdate){
         
             System.debug('After insert and update function');
             if(RecursiveTriggerHandler.isFirstTime){
                  RecursiveTriggerHandler.isFirstTime = false;
             for (Contact con : Trigger.new) {    
       
                Contact contacttoUpdate = con.clone(true,true);
                contacttoupdate.Nickname__c=contacttoUpdate.firstname;
                listofContacts.add(contacttoUpdate);  
                if (Trigger.oldMap.get(con.Id).checkbox==false  &amp;&amp; con.checkbox== true) {  
               
                   usersToCreate.add(contacttoUpdate);
                }        
             }
  
             
             
            
             
             
             
             ContactTriggerHandler.AfterInsert(usersToCreate);
             update listofContacts;
  
            }
         
        }
  
     }
  
  }
  </code></pre>
  <p>Here is the recursive handler class:</p>
  <pre><code>public class RecursiveTriggerHandler{
     public static Boolean isFirstTime = true;
  }
  </code></pre>