Activity › Forums › Salesforce® Discussions › What is the difference between the old and the new version of sobject records in Salesforce Trigger?
Tagged: Context Variables, Custom objects, Salesforce Database, Salesforce sObject, Salesforce Trigger, sObject Type, SObjects Records
-
What is the difference between the old and the new version of sobject records in Salesforce Trigger?
Posted by Pooja on January 27, 2020 at 7:55 AMWhat is the difference between the old and the new version of sobject records in Salesforce Trigger?
Marziya replied 6 years, 3 months ago 4 Members · 3 Replies -
3 Replies
-
Hi Pooja,
New version returns List of new records before inserting into the Database.
This is available in Before Insert, Before Update, After Insert, After Update Triggers and Undelete Triggers.
Old version returns List of old records which are already inserted into the Database.
This is available in Before update, after update, Before Delete and After Delete triggers.
Hope it helps!
- [adinserter block='9']
-
Hi,
Trigger.new : Returns a list of the new versions of the sObject records. Note that this sObject list is only available in insert and update triggers, and the records can only be modified in before triggers.
Trigger.old : Returns a list of the old versions of the sObject records. Note that this sObject list is only available in update and delete triggers
-
hii pooja,
Trigger.New and Trigger.Old are both the context Variables which returns records in Lists.
Trigger.New => works for the NEW values that are entering either it may be Insert or Update.
Trigger.Old=> works for the OLD values that are already in the Fields, it may be to Delete or Update the records.********************#########################***********************************
Trigger.old: Returns a list of the old versions of the sObject records.Note that this sObject list is only available in the update and delete triggers.
Trigger.oldMap: A map of IDs to the old versions of the sObject records. Note that this map is only available in the update and delete triggers.
suppose you have a custom object Custom_obj__c
Trigger.old means it is a List<Custom_obj__c>.
Log In to reply.