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, 4 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

    How Do Salesforce AppExchange Apps Drive Business Growth?

    Blog in Salesforce

    Why do some AppExchange apps become huge successes while others barely get noticed? The secret lies in smart planning. AppExchange connects app developers with millions…

    Appexchange App Development, Salesforce AppExchange Development, Salesforce AppExchange Development Company, salesforce appexchange development services, salesforce partners appexchange
    Elena Nov 24, 2025
    384  Views

    What is Schema Builder in Salesforce? | All You Need to Know

    Blog in Salesforce Admin

    Schema Builder is a graphical tool in Salesforce that allows you to create, modify, and visualize data models of your Salesforce organization. It provides an…

    Auto-Layout, Collaboration, Create, Custom Fields, custom object
    Arpit Jul 20, 2023
    2,280  Views

    Salesforce Service Cloud Implementation 2025: Boost Customer Satisfaction and Efficiency

    Blog in Others

    Customer expectations are higher than ever—and in 2025, businesses can’t afford to deliver anything less than exceptional service. To stay ahead, organizations are turning to…

    Anna Oct 14, 2025
    307  Views

    Popular Salesforce Videos

    How you can Increase your Salesforce Efficiency and Productivity

    How you can Increase your Salesforce Efficiency and Productivity

    Video in Salesforce Training

    In this video, Brad discusses how to increase your workplace efficiency and productivity using various Google Chrome extensions and techniques. As always, we have linked…

    Salesforce Developer, salesforce, SFDC, Salesforce.com, Google Chrome
    Bradley Jun 3, 2020
    2,288  Views
    Salesforce Stock CRM Huge News!

    Salesforce Stock CRM Huge News!

    Video in Others, Salesforce Stories

    Why is Salesforce Stock CRM Stock going UP? Is Salesforce stock a buy? Should I buy CRM Stock? Is Salesforce stock a good investment? In…

    salesforce, Salesforce Video, Salesforce Stock, CRM Stock, Salesforce Stock CRM
    Nauman Sep 4, 2020
    1,742  Views
    Salesforce Apex Trigger Best Practices | Learn Salesforce Series By Algoworks

    Salesforce Apex Trigger Best Practices | Learn Salesforce Series By Algoworks

    Video in Salesforce Apex

    In this video, the following points will be covered - 1. One Trigger Per Object 2. Logic-less Triggers 3. Context-Specific Handler Methods 4. Code Bulkification…

    Salesforce Consultant, Salesforce Apex Trigger, Testing, support, Learn Salesforce Series
    Algoworks Sep 10, 2020
    3,072  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.