Toggle Side Panel

  • Blogs
  • 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
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Blogs
    • 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
    • Contact Us
    • Discussions
    Close search

    Activity › Forums › Salesforce® Discussions › Get the inserted record id in a upsert call?

    Tagged: Account, DML Operation, Salesforce Controller, SET, Upsert

    • Salesforce® Discussions

      Get the inserted record id in a upsert call?

      Posted by Ravi on April 28, 2016 at 8:49 AM

      I am doing following DML in my controller

      upsert accountList Eid__c;

      After upsert, I need the Id of only inserted Account

      for(Account insertedAccount : accountList){
             System.debug('AccountId>>>'+insertedAccount.id+'<<<<AccountId');
      }

      I am getting id of all account.

      Shubham replied 10 years, 5 months ago 2 Members · 1 Reply
      • Account
      • DML Operation
      • Salesforce Controller
      • SET
      • Upsert
    • 1 Reply
    • Shubham

      Member
      April 28, 2016 at 9:57 AM

      you can use a Set of Id and before upsert dml iterate over list and collect all ids

      `set accIds = new set();
      for(Account accObj : accountList){
      if(accObj.Id != null) accIds.add(accObj.Id);
      }
      upsert accountList Eid__c;

      for(Account insertedAccount : accountList){
      if(!accIds.contains(insertedAccount.Id))
      {
      system.debug('*** Id = ' + insertedAccount.id);
      }
      }`

    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

    Popular Salesforce Blogs

    Salesforce Error Apex

    How To Resolve When Salesforce Error Apex Heap Size Too Large

    Blog in Salesforce Apex

    Salesforce upholds an Apex Heap Size Limit of 6MB for synchronous execution and 12MB for Asynchronous execution. The "Pinnacle stack size excessively huge" mistake happens…

    Asynchronous Execution, Class-level Variables, Code, Developers, Error:apex
    Aditya Jun 17, 2021
    45,720  Views
    Salesforce tips

    Learn Everything About Salesforce: Top Tips From Students

    Blog in Salesforce

    Student life is always hectic. With an abundance of assignments, it is no surprise that students don’t have enough time to do sports and attend…

    App Building, Assignments, B2C and B2B Commerce, Boost Sales, Build Enterprise-quality Applications
    Kim Brooks Jun 14, 2021
    2,724  Views

    8 Ways a Salesforce LMS Integration Can Improve Customer Training

    Blog in Salesforce integration

    Integrating an LMS with Salesforce is beneficial as an LMS acts as a database of learning resources for your salesperson. It can also provide your employees with the band the positive behaviors…

    Assignment Rules, Certain Customer, Certificates, Completions, Compliance Certifications
    Pradnya Maske Jun 7, 2021
    4,350  Views

    Popular Salesforce Videos

    Smart Merchandising with Salesforce Einstein AI

    Smart Merchandising with Salesforce Einstein AI

    Video in AI and ML, Salesforce Einstein

    Smart Merchandising is a holistic tool that magically combines rich insights from site-wide search, navigation, purchases, and the customer’s current session with strategic business goals.…

    Salesforce Training, Salesforce Video, Customers, Salesforce Learning, Business
    Algoworks Jun 30, 2021
    1,781  Views
    Lesser Known VSCode Tips for Salesforce Developers

    Lesser Known VSCode Tips for Salesforce Developers

    Video in Salesforce Stories

    More Code, Less Work. Whether you are a beginner or an advanced developer, smart tips, and sharp tools can significantly improve your productivity. There are…

    Salesforce Training, Salesforce Developers, Salesforce Video, Salesforce Learning, VSCode
    Rupal Kakkar Nov 13, 2020
    1,650  Views
    Salesforce Einstein Top FAQs'

    Salesforce Einstein Top FAQs'

    Video in Salesforce Einstein

    We hear a lot of questions from people regarding Salesforce Einstein which is why we've answered them below. So that you have complete and top…

    Salesforce Products, Salesforce Jobs, salesforce, CRM, Salesforce Einstein
    Algoworks Sep 14, 2020
    1,702  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

    © 2026 - 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®.

    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.