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 › how we can edit the description of account through Salesforce Apex code?

    Tagged: Account Detail, Randomization, Salesforce Apex, Salesforce Apex Code

    • Salesforce® Discussions

      how we can edit the description of account through Salesforce Apex code?

      Posted by Shubham on July 31, 2017 at 11:20 AM

      I want to edit randomly selected account from our list of account?

      shariq replied 7 years, 11 months ago 4 Members · 3 Replies
      • Account Detail
      • Randomization
      • Salesforce Apex
      • Salesforce Apex Code
    • 3 Replies
    • Radhakrishna

      Member
      August 1, 2017 at 8:23 AM

      Hello Shubham,

       

      You need to create new "instance" of Account and need to add Id and RecordTypeId in it to update.

      Right now in your code it is taking entire object returned from SOQL. Rather than updating same list you received from SOQL, create new list of Account and update that.

      Put this line before SOQL on account.
      List<Account> = new List<Account>();

      Wherever you are setting RecordTypeId, set following code for adding account in list of Accounts to be updated.

      Account a = new Account(
      Id = acc.Id,
      RecordTypeId = rt.Id
      );
      AccListToBeUpdated.add(a);

      Let me know if any issues. Mark it as best answer if it works!

    • [adinserter block='9']
    • Parul

      Member
      September 17, 2018 at 6:40 AM

      List<Account> = new List<Account>();

      Account a = new Account(
      Id = acc.Id,
      RecordTypeId = rt.Id
      );
      AccListToBeUpdated.add(a);

      May be it helps

      Thanks.

    • shariq

      Member
      September 17, 2018 at 12:19 PM

      Hi Parul,RadhaKrish

      I have executed your code and it didn't work out for me. You are using account id but you didn't specify the source of these account id's and Also,you didn't specify anything about description in your apex code and you haven't perform any DML operations as well. Below snippet of code worked for me :

      list<account> accountList = new list<account>();
      accountList = [select id,Description from Account Limit 100];
      if(accountList.size() > 0){
      for(Account acc :accountList){

      acc.Description = 'Test';
      }

      update accountList;
      }

      Hope this helps!

      • This reply was modified 7 years, 11 months ago by  shariq.

    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

    Einstein Analytics

    Reinforcing Fintech Companies, Salesforce Extends Einstein Analytics For Financial Services Cloud!

    Blog in AI and ML, Analytics, Salesforce Einstein

    There has been a rapid change in the banking and wealth management industry, lately. Several modern fintech competitors have stepped in to simplify the ways…

    CRM, Customer Relationships, Einstein Analytics, Financial Services Cloud, Royal Bank of Canada
    Algoworks Sep 23, 2019
    3,288  Views
    History of CRM

    What is The History of CRM and How is it Important in Today's Day and Age? | Salesforce

    Blog in Others, Salesforce

    Customers are the most important asset to any business no matter what industry you belong to, what your focus is, or what kind of products…

    Artificial Intelligence, Blockchain, Business, Business Intelligence Services, Business Needs
    Apphienz Mar 10, 2021
    2,214  Views

    5 Ways Salesforce CPQ can Transform Your Sales Process

    Blog in Others

    You understand the value of streamlining your sales process as a salesman. You can spend more time completing business if you spend less time making…

    Automated Quoting, Automates, Automating Configuration, Better Reporting, Boost Efficiency
    Eden May 18, 2023
    1,877  Views

    Popular Salesforce Videos

    How to Find out Who Deleted a Record in Salesforce

    How to Find out Who Deleted a Record in Salesforce

    Video in Others, Salesforce Admin

    Salesforce administrators can determine who deleted a record by looking at the Recycle Bin or querying for deleted records via API. Watch this video and…

    Salesforce Training, Salesforce Tutorial, Salesforce Video, Salesforce Learning, Salesforce Administrators
    Prafull Feb 10, 2021
    3,830  Views
    Salesforce Nonprofit Success Pack Implementation Guide

    Salesforce Nonprofit Success Pack Implementation Guide

    Video in Salesforce For Nonprofits

    There are so many things to consider when using Salesforce Nonprofit Success Pack for your nonprofit organization that it can be tricky to know where…

    Salesforce Training, Salesforce Tutorial, Salesforce Development, Salesforce Implementation, salesforce
    DB Aug 23, 2023
    1,389  Views
    Salesforce To RDS Integration Through Dell Boomi | Salesforce Tutorial

    Salesforce To RDS Integration Through Dell Boomi | Salesforce Tutorial

    Video in Salesforce Integration, Salesforce Training

    Salesforce to RDS integration through Dell Boomi. This tutorial will cover the following points - 1. Introduction Take a quick glimpse at integrating accounts from…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Video, Dell Boomi
    Algoworks Dec 23, 2020
    3,053  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.