Trigger Old Context Variables (oldMap, old)

According to the documentation, Trigger.old and Trigger.oldMap are only available in update and delete Triggers.

Are these variables null otherwise, or are they just empty? Would Trigger.old.isEmpty() return true if it’s referenced in an insert Trigger?


Trigger.Old is null in a Before Trigger and will therefore throw a NullPointerException for any reference / method invocation on it.

16:08:40.060 (60355000)|USER_DEBUG|[2]|DEBUG|**** Trigger.old null
16:08:40.060 (60362000)|SYSTEM_METHOD_EXIT|[2]|System.debug(ANY)
16:08:40.060 (60503000)|FATAL_ERROR|System.NullPointerException:
Attempt to de-reference a null object

Source : Link , Question Author : Matt K , Answer Author : techtrekker

Leave a Comment