Activity Forums Salesforce® Discussions What is the return type of Trigger.Old and Trigger.OldMap in Salesforce?

  • shradha jain

    Member
    July 30, 2018 at 6:41 am

    Hello Sanjana,

    Trigger.old: Returns a list of the old versions of the sObject records. Trigger.old should return a type ofList<sObject__c>.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. Trigger.oldMap should return a type of Map<Id, sObject__c>.Note that this map is only available in the update and delete triggers.

  • Parul

    Member
    September 14, 2018 at 4:46 am

    Trigger.oldMap & Trigger.New are returning the same information on after update trigger

     

    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

    Example:
    Trigger.old means it is a List<Custom_obj__c>
    and

    Example:
    Trigger.oldMap means it is a map<Id, Custom_obj__c>

     

    THanks

  • shariq

    Member
    September 15, 2018 at 2:10 pm

    Hi,

    Trigger.old - It returns a list of sobject records.

    Trigger.oldMap - It returns a map of Id vs Sobject record.

    Hope this helps.

  • Keyur Nandaniya

    Member
    December 9, 2019 at 10:51 am

    Hello sanjana,

    Trigger.old will return list of sObject like {name:'xyz', id:'sasdasdabcgyaASD'}, and

    Trigger.OldMap will return Map of ID,sObject like (id:'asdmsudbhjSAD':{name:'xys',AccountId:'asdasdasdDSA'})

  • Deepak

    Member
    December 9, 2019 at 2:04 pm

    Trigger.old: Returns a list of the old versions of the sObject records. Trigger.old should return a type ofList<sObject__c>.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. Trigger.oldMap should return a type of Map<Id, sObject__c>.Note that this map is only available in the update and delete triggers.

  • Sumit

    Member
    January 29, 2020 at 11:56 am

    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

Log In to reply.

Popular Salesforce Blogs