Activity Forums Salesforce® Discussions How is Trigger.New different from Trigger.newMap in Salesforce?

  • shradha jain

    Member
    July 19, 2018 at 9:38 am

    Hello Avnish,

    Trigger.New is simply a list of the records being processed by the trigger, so if all you need to do is loop through them then you can use that. It returns a list which is ordered. Suppose you have a custom object Custom_obj__c then  Trigger.New is a list represented as  List<Custom_obj__c>.

    Trigger.newMap just allows you to target specific records by Id should you not need to process everything, or if you need to map other records back to these. It returns a map which is unordered. Trigger.newMap  is a map represented as  map<Id, Custom_obj__c>.

    • This reply was modified 6 years, 4 months ago by  shradha jain.
    • This reply was modified 6 years, 4 months ago by  shradha jain.
  • shariq

    Member
    September 16, 2018 at 1:38 pm

    Hi,

    To understand it more simple -

    Trigger.new - it return the list of sobject's records.

    Trigger.newMap - It returns the map of Id vs sobject record.

    Hope it helps.

  • Parul

    Member
    September 16, 2018 at 2:45 pm

    Trigger.New is simply a list of the records being processed by the trigger. It returns a list which is ordered. Suppose you have a custom object Custom_obj__c then  Trigger.New is a list represented as  List<Custom_obj__c>.

    Trigger.newMap just allows you to target specific records by Id should you not need to process everything. It returns a map which is unordered. Trigger.newMap  is a map represented as  map<Id, Custom_obj__c>.

     

    Thanks

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos