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

    10 Reasons to Switch On Salesforce Lightning

    Blog in Lightning, Others

    It's been close to 12 months since Salesforce propelled its greatest advancement yet, Lightning.  The achievement checked considerably more than a facelift for our items.…

    AppExchange Apps, Applications, Applications and Pages, Assistant, Client Experience
    Pooja Sep 16, 2020
    3,643  Views

    Close Case Button in Lightning Experience - Workaround

    Blog in Lightning

    If you have Used Cases in Salesforce, I am sure you’re aware of the Closed Case layout.  This is great, it lets you require the…

    Case Management, Close Case, FieldSet in Salesforce, Lightning, Lightning Experience
    Jade Feb 5, 2019
    41,564  Views

    The Role of Salesforce Einstein in Marketing, Sales, and Services

    Blog in Sales, Salesforce Einstein

    Salesforce Einstein is an Artificial Intelligence technology launched for the Salesforce Customer Success Platform. With Salesforce Artificial Intelligence, you can increase the potential of marketing,…

    Artificial Intelligence, Artificial Intelligence for Marketing, Artificial Intelligence for Sales, Artificial Intelligence for Service, Customer Foresight
    Algoworks Apr 16, 2020
    2,448  Views

    Popular Salesforce Videos

    Entrepreneurship in the Salesforce Ecosystem

    Entrepreneurship in the Salesforce Ecosystem

    Video in Salesforce Stories

    The Salesforce Women’s Entrepreneur Group is a group of women who have founded and own businesses in the Salesforce ecosystem. Our goal is to inspire,…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Ecosystem, Salesforce Video
    Pooja Apr 12, 2021
    1,818  Views
    How To Become A Salesforce Administrator | Salesforce Administrator Training

    How To Become A Salesforce Administrator | Salesforce Administrator Training

    Video in Salesforce Training, Salesforce Development

    What does Salesforce developer do? Salesforce developers lead the testing and implementation of software development efforts, including coding, configuration, maintenance, installation, testing, and debugging, as…

    Salesforce Training, Salesforce Developer, Learn Salesforce, Salesforce Video, Testing
    Rupal Kakkar Jul 29, 2021
    1,922  Views
    Salesforce Pardot: 2020 Update

    Salesforce Pardot: 2020 Update

    Video in Salesforce Stories, Salesforce Products

    If you’re a current Salesforce user, you may be hearing a lot about Pardot these days. Perhaps you are using MailChimp, Campaign Monitor, or Constant…

    salesforce, Marketing Automation, Salesforce Video, Trailblazer, Leads
    Algoworks Oct 15, 2020
    1,303  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

    © 2025 - 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.