Toggle Side Panel

  • Home
  • Articles
    • All Articles
    • Blogs
    • Videos
    • Infographics
  • Consultants
    • Salesforce Product Expertise
      • Top Salesforce ConsultantsTop Salesforce Consultants
      • Marketing Cloud ConsultantsMarketing Cloud Consultants
      • Service Cloud ConsultantsService Cloud Consultants
      • Experience Cloud ConsultantsExperience Cloud Consultants
      • Analytics Cloud ConsultantsAnalytics Cloud Consultants
    • Salesforce Industry Expertise
      • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
      • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
      • Health Cloud ConsultantsHealth Cloud Consultants
      • Commerce Cloud ConsultantsCommerce Cloud Consultants
      • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
    • Salesforce Experts by Location
      • USATop Salesforce Consultants in USA
      • IndiaTop Salesforce Consultants in India
      • AustraliaTop Salesforce Consultants in Australia
      • United KingdomTop Salesforce Consultants in UK
      • CanadaTop Salesforce Consultants in Canada
  • Webinars
  • Marketplace
  • Advertise With Us
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Home
    • Articles
      • All Articles
      • Blogs
      • Videos
      • Infographics
    • Consultants
      • Salesforce Product Expertise
        • Top Salesforce ConsultantsTop Salesforce Consultants
        • Marketing Cloud ConsultantsMarketing Cloud Consultants
        • Service Cloud ConsultantsService Cloud Consultants
        • Experience Cloud ConsultantsExperience Cloud Consultants
        • Analytics Cloud ConsultantsAnalytics Cloud Consultants
      • Salesforce Industry Expertise
        • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
        • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
        • Health Cloud ConsultantsHealth Cloud Consultants
        • Commerce Cloud ConsultantsCommerce Cloud Consultants
        • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
      • Salesforce Experts by Location
        • USATop Salesforce Consultants in USA
        • IndiaTop Salesforce Consultants in India
        • AustraliaTop Salesforce Consultants in Australia
        • United KingdomTop Salesforce Consultants in UK
        • CanadaTop Salesforce Consultants in Canada
    • Webinars
    • Marketplace
    • Advertise With Us
    • Contact Us
    • Discussions
    Close search

    Activity › Forums › Salesforce® Discussions › What is the use of oldMap and newMap context variables in Salesforce Triggers?

    Tagged: Account ID, Account Record, Context Variables, DML Operations, Salesforce Records, Salesforce Triggers, sObject List Type, Trigger New, Trigger NewMap, Trigger Old, Trigger OldMap, Update, Variables and Methods

    • Salesforce® Discussions

      What is the use of oldMap and newMap context variables in Salesforce Triggers?

      Posted by Anurag algoworks on July 30, 2018 at 11:22 AM

      What is the use of oldMap and newMap context variables in triggers and how are they different from 'old' and 'new' context variables?

      Parul replied 7 years, 2 months ago 4 Members · 4 Replies
      • Account ID
      • Account Record
      • Context Variables
      • DML Operations
      • Salesforce Records
      • Salesforce Triggers
      • sObject List Type
      • Trigger New
      • Trigger NewMap
      • Trigger Old
      • Trigger OldMap
      • Update
      • Variables and Methods
    • 4 Replies
    • Anjali

      Member
      July 30, 2018 at 1:11 PM

      Hello Anurag

      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. Trigger.new will have current details of the record getting inserted or updated, where as trigger.old will have the existing details for a record before it is updated or deleted.

      Trigger.OldMap: A map of IDs to the old versions of the sObject records. Note that this map is only available in update and delete triggers.

      Trigger.new: Trigger.new is a list of sobjects. If we are talking about a DML operation on account, then trigger.new is simply a list of accounts. Similarly when used in contact trigger, trigger.new becomes a list of contacts.

      Trigger.newMap: Trigger.newMap is a map with key as ID of the record and value as the record itself. Just like the above explanation, in case of accounts when we say trigger.newMap we are talking about a map of key-value pairs where the key is the account ID and the value is the account record itself.

    • Parul

      Member
      September 18, 2018 at 7:36 AM

      Trigger.OldMap: A map of IDs to the old versions of the sObject records. Note that this map is only available in update and delete triggers.

      Trigger.newMap: Trigger.newMap is a map with key as ID of the record and value as the record itself. Just like the above explanation, in case of accounts when we say trigger.newMap we are talking about a map of key-value pairs where the key is the account ID and the value is the account record itself.

      A map of IDs to the new versions of the sObject records.Note that this map is only available in before update, after insert, and after update triggers.
      oldMap
      A map of IDs to the old versions of the sObject records.Note that this map is only available in update and delete triggers.

       

      Thanks

    • shariq

      Member
      September 21, 2018 at 12:25 AM

      Hi,

      Trigger.new return the ordered list whereas trigger.newmap returns a map which is unordered

      In otherways

      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.NewMap
      A map of IDs to the new versions of the sObject records, this map is only available in before update, after insert, and after update triggers.

      Hope this helps.

    • Parul

      Member
      September 21, 2018 at 4:41 AM

      Hi , Difference in oldMap and newMap

      //Trigger.new: Contains all new Data
      //Trigger.Old: Contains all old Data (before change)
      //Trigger.newMap: Map contains new Data (Key: Id)
      //Trigger.oldMap: Map contains old Data (Key: Id)
      for(Opportunity opp:Trigger.New){
      if(opp.Stage != Trigger.oldMap.get(opp.Id).Stage){
      //Your logic
      }
      }
      //Same way you can use Trigger.newMap

      I hope this will helpfull to you.

      Thanks

       

    Log In to reply.

    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me

    application solution

    Popular Salesforce Blogs

    Value of Salesforce in Small and Medium Business

    Blog in Others

    Speed is the quintessence of the business world. That is valid for almost every part of our business, yet it's particularly valid for innovation and…

    Business Operations, Business Success, Community Cloud, Dreamforce, Marketing Cloud
    Christi Mar 6, 2018
    3,717  Views
    Salesforce Licenses

    Understanding About All the Salesforce Licenses and its Types

    Blog in Salesforce

    Salesforce Licenses Salesforce provides licenses for its users to access their company data. These licenses are available on the Company Information page. Developer Edition Organization…

    Chatter, Company Data, Customer Portal Manager, Customer Portal Manager License, Developer Edition Organization
    Nikhil Kumar Sep 27, 2022
    2,902  Views

    Einstein Prediction Builder: Next Steps to Build an Automated Flow

    Blog in Others

    This article is prepared by our Salesforce Administrator Dzmitry Pimenau. Automation of Actions based on Predictions In the first part of the article we described the…

    Automated Flow, Branch Logic, Branch Merge, Configuration, CRM
    Vimera | Andersen Mar 20, 2024
    1,110  Views
    Footer Forcetalks logo

    support@forcetalks.com

    • twitterx

    Quick Links

    Advertise with Us

    Salesforce® Articles

    Dreamforce 2023

    Top Salesforce® Bloggers 2023

    Top Salesforce Consultants

    Get Listed

    Company

    Contact Us

    About Us

    Privacy Policy

    Terms & Conditions

    InsightHub

    Salesforce Blogs

    Salesforce Videos

    Salesforce Groups

    Salesforce Jobs

    © 2025 - Forcetalks ● All Rights Reserved

    Salesforce® is a trademark of Salesforce® Inc. No claim is made to the exclusive right to use “Salesforce”. Any services offered within the Forcetalks website/app are not sponsored or endorsed by Salesforce®.

    Try AuditMyCRM - It is a Salesforce CRM Audit tool which comprehensively scans your Salesforce org and gives you the list of errors or warnings you need to take care of.
    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.