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

    Why Salesforce is the Most Preferable CRM for Businesses?

    Blog in Salesforce

    In the realm of CRM, Salesforce has emerged as one of the most powerful and embraced solutions with maximum users acceptance rate. The market share…

    AppExchange Platform, Business, Business Growth, Business Needs, Business Operations
    Fexle Services Aug 4, 2021
    5,328  Views
    Salesforce-Powered Communities

    Employee Onboarding Made Easy With Walk-Throughs on Salesforce-Powered Communities

    Blog in Salesforce

    We are currently in the midst of a learning revolution. Technology has given us the tools to build learning programs that meet individual learners where…

    Application, Businesses, Career Development, Career Needs, Change Management
    Grazitti Jun 3, 2022
    2,566  Views

    Upgrade from Salesforce Nonprofit Success Pack to Salesforce Nonprofit Cloud

    Blog in Salesforce Products

    As the needs of nonprofits evolve, so does the technology that supports them. Salesforce recently introduced the new Nonprofit Cloud, an upgrade that promises to…

    Benefit Assignment, Benefit Object, Benefit Schedules, Benefit Sessions, Benefit Type
    DB Nov 11, 2025
    101  Views

    Popular Salesforce Videos

    Unleash Your Salesforce Process Automation With This New Connector For Salesforce Lightning Platform

    Unleash Your Salesforce Process Automation With This New Connector For Salesforce Lightning Platform

    Video in Salesforce Automation

    Unleash your Salesforce process automation with this new Connector for Salesforce Lightning Platform (a set of 130 Activities and 5 wizards that allow you to…

    Salesforce Lightning, Salesforce CRM, Salesforce Lightning Platform, Salesforce Process Automation, New Connector
    Cristian Jul 9, 2020
    2,288  Views
    Powering Dynamic Gamification on Salesforce Communities With ScoreNotch

    Powering Dynamic Gamification on Salesforce Communities With ScoreNotch

    Video in Others

    Gamifying your online community helps you drive highly-engaging user experiences. While you can host your community on Salesforce Experience Cloud, there are limitations with regard…

    Salesforce Training, Salesforce Tutorial, User Experience, Salesforce Video, Salesforce Learning
    Sushmita Mehta Feb 28, 2022
    2,230  Views
    9 Stages of Identity & Access Management Lifecycle | Salesforce Tutorial

    9 Stages of Identity & Access Management Lifecycle | Salesforce Tutorial

    Video in Salesforce Certifications

    Grow your architect skills and expertise in the area of Identity and Access Management. This video explains the 9 stages of Identity & Access Management…

    Salesforce Training, Salesforce Tutorial, Salesforce Video, Salesforce Learning, Salesforce Architect
    Abhishek Jul 16, 2021
    1,978  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.