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 Commerce Cloud for E-Commerce

    Blog in Salesforce Cloud Platform

    What Is Commerce Cloud? Commerce Cloud is one of the eight product clouds that make up the Salesforce Intelligent Customer Success Platform. Along with Sales…

    Commerce Cloud Order Management, Customer Insights, Customer Success Platform, Digital Commerce Cloud, Einstein Commerce Cloud
    Jade Feb 4, 2019
    7,986  Views

    Why Every Small & Medium Business Need Salesforce Implementation

    Blog in Salesforce Implementation

    Salesforce CRM is getting popular these days among every enterprise, due to its capabilities. The cloud-based CRM is being an extensively useful developing technology, changing…

    AppExchange, Apps on AppExchange, Business Operation, Business Outlook, Business Product Manager
    SaaSnic Aug 18, 2020
    6,298  Views
    Salesforce Software Engineer

    Salesforce Software Engineer: The future

    Blog in Salesforce Consultant

    What is a Salesforce Consultant? A Salesforce Consultant conventionally wears different covers. They might work in-house inside an association or be contracted as an external…

    Business, Business Cycles, Business Examinations, Business Experience, Business Issues
    Anna Dec 30, 2021
    3,972  Views

    Popular Salesforce Videos

    Add In-App Guidance to Salesforce Lightning Experience

    Add In-App Guidance to Salesforce Lightning Experience

    Video in Lightning

    In Lightning Experience, add prompts that appear on-screen to users working in an app. Use prompts to onboard and train users, highlight configuration changes and…

    Salesforce Lightning, Salesforce Lightning Experience, salesforce, CRM, Salesforce VIdeos
    Abhai Deep Mar 18, 2020
    4,416  Views
    TrailheaDX '18 Opening Keynote - Part 6: Skill Up Everyone

    TrailheaDX '18 Opening Keynote - Part 6: Skill Up Everyone

    Video in Trailhead

    Related Videos: Salesforce TrailheaDX ’18 Opening Keynote – Part 1: Create Connected Customer Experiences TrailheaDX ’18 Opening Keynote – Part 2: Salesforce Platform TrailheaDX ’18…

    Salesforce Einstein, How To Learn Trailhead, Lightning App Builder, Salesforce Keynote, Salesforce App Development
    Abhay Apr 5, 2018
    2,193  Views
    How To Use Salesforce Campaigns in Pardot

    How To Use Salesforce Campaigns in Pardot

    Video in Salesforce Stories

    Learn campaign basics to help you plan your marketing strategy. In this video, Pardot experts guide you in: - Defining campaigns in Pardot and Salesforce…

    Salesforce Training, salesforce, Salesforce Video, Campaign Members, Salesforce Learning
    Pooja May 19, 2021
    3,288  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.