Activity Forums Salesforce® Discussions What is the difference between the old and the new version of sobject records in Salesforce Trigger? 

  • Deepak

    Member
    January 27, 2020 at 8:25 am

    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!

  • Sumit

    Member
    January 27, 2020 at 2:07 pm

    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

  • Marziya

    Member
    January 27, 2020 at 2:08 pm

    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.

Popular Salesforce Blogs

Popular Salesforce Videos