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 › 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 9 years, 8 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

    application solution

    Popular Salesforce Blogs

    Salesforce CPQ Implementation

    Best Salesforce CPQ Implementation Practices to Follow

    Blog in Salesforce Products

    Understanding what the customer needs, keeping an account of all their custom preferences, and pricing is a huge task in itself. Sales teams begin with…

    B2B, B2B Organizations, B2B Quoting Process, B2C Use Case B2B, Bundles and Configuration
    Bolt Sep 19, 2022
    3,242  Views

    How To Be A Salesforce Developer?

    Blog in Salesforce

    From 2014, unarguably the best way to start learning Salesforce is through Trailhead. Think of it as the best university to enroll yourself in for…

    Aura Components, Back-end Development, Back-end Programming, Code Redundant, Continuous Learning
    Apphienz Mar 18, 2021
    2,418  Views

    Salesforce to Salesforce Integration Using REST API

    Blog in Others

    After learning the REST API, it's always good to do some practice to make the concept more clear. In this Blog, we will Integrate Two…

    connected app, OAuth, Rest API, Salesforce Integration, Salesforce to Salesforce Intgration
    Suraj Apr 6, 2017
    21,169  Views

    Popular Salesforce Videos

    How to Get Your Data In and Get Insights Out | Salesforce Essentials

    How to Get Your Data In and Get Insights Out | Salesforce Essentials

    Video in Data

    Organize all your data with Salesforce Essentials. With a quick and easy import, you’ll be able to manage your business and watch it grow. Essentials…

    Salesforce Training, Salesforce Data, Salesforce Video, Salesforce Essentials, Salesforce Learning
    Jogender Aug 10, 2020
    1,666  Views
    Getting Information from your Salesforce Account for a Salesforce Connection

    Getting Information from your Salesforce Account for a Salesforce Connection

    Video in Salesforce Stories

    Watch this video to learn how to get information from your Salesforce Account for a Salesforce Connection. Do let us know in the comment section…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Video, Salesforce Account
    Pooja Jun 17, 2022
    1,279  Views
    Salesforce Admin Mock Interview Questions and Answers

    Salesforce Admin Mock Interview Questions and Answers

    Video in Salesforce Admin

    In this Salesforce Mock Interview Series, I'm dropping the seventh podcast/video of the Salesforce Admin Mock Interview Questions and Answers. This will help you to…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Community, Salesforce Admin
    Vivek Jul 8, 2022
    2,419  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®.

    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.