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

    Batch Class in Salesforce

    All About Batch Class in Salesforce | The Developer Guide

    Blog in Salesforce Apex

    Batch Apex is used to run large jobs (think thousands or millions of records!) that would exceed normal processing limits. Each time you invoke a…

    Batch, Batch Apex, Batch Class, Batch Class Code, Batch Class in Salesforce
    Arpit Oct 26, 2021
    4,656  Views

    How to Find a Salesforce Partner: Guide on Evaluation Criteria & Cost Range

    Blog in Salesforce Consultant

    Despite Salesforce having powerful out-of-the-box solutions and features, at certain stages of the business lifecycle, it requires customizations, integration, and other configurations to be legally…

    Guide, Partner Community, salesforce partners, salesforce-business-process
    Sparkybit Mar 22, 2024
    1,148  Views
    What are field dependency?

    What are Field Dependencies in Salesforce in 2023? | All You Need to Know

    Blog in Others

    Salesforce is a powerful CRM platform that allows businesses to customize and tailor the software to their specific needs. One of the ways this is…

    automation tools, Best Practices, Complexity, Consistency, Controlling Field
    Mohit Kumar Apr 20, 2023
    2,797  Views

    Popular Salesforce Videos

    Integrate Salesforce with External System using REST API

    Integrate Salesforce with External System using REST API

    Video in Salesforce Integration

    In this video, Path to Code explains the following topics: - What is API? - Introduction to REST API - Using cURL to consume Rest…

    Salesforce Training, Salesforce Tutorial, Salesforce Apex, Salesforce Integration, salesforce
    Tulika Wadhwani Oct 31, 2022
    2,005  Views
    Creating a Rollup Using DLRS | Salesforce Tutorial

    Creating a Rollup Using DLRS | Salesforce Tutorial

    Video in Salesforce Training, Salesforce Admin

    In certain situations, an object does not support a roll-up, or the relationship is not permitted. Learn how to make it possible by using the…

    Salesforce Training, Salesforce Tutorial, Salesforce Video, Salesforce Learning, Salesforce Architect
    SkyPlanner Jul 16, 2021
    2,398  Views
    Custom Button URL Hacking in Salesforce Lightning Experience vs Salesforce Classic

    Custom Button URL Hacking in Salesforce Lightning Experience vs Salesforce Classic

    Video in Lightning, Salesforce Training

    Custom Button URL Hacking in Salesforce Lightning Experience vs Salesforce Classic Custom button URL Hacking approach in Salesforce Classic Custom button URL Hacking approach in…

    Salesforce Training, Salesforce Tutorial, Salesforce Lightning, Salesforce Lightning Experience, Salesforce Classic
    Jogender Apr 27, 2021
    2,089  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.