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 8 years 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 8 years 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

    Choosing Between Salesforce Consulting Firms and Freelancers: What Gets You the Best ROI?

    Blog in Others

    Managing a modern business means juggling multiple tools, systems, and strategies—and Salesforce often sits at the center of it all, from CRM to customer support…

    Dean Sep 9, 2025
    649  Views
    Use Cases of JavaScript in Salesforce - Change Table Row Colours on the basis of criteria

    Use Cases of JavaScript in Salesforce: Change Table Row Colours on the basis of criteria

    Blog in Coding and Scripting, Salesforce Implementation

    In the ever-changing technological era, we often come across a new programming language that is being introduced to match the requirements of current problems and…

    JavaScript, JavaScript framework, Javascript in Salesforce, JavaScript Libraries, JavaScript Table
    BLUE FLAME LABS PRIVATE LIMITED Feb 13, 2018
    8,737  Views
    Data Security Models

    Data Security Models in Salesforce

    Blog in Salesforce Security

    In Salesforce when we talk about security and especially about data security, so our main focus is to provide more security and try to prevent…

    Assigning a Permission Set, Baseline Level, Control Data Access, Custom Profiles, Data Security
    kishan Apr 27, 2021
    4,132  Views

    Popular Salesforce Videos

    Introduction to Lightning Web Components | Hello World | Key Concepts

    Introduction to Lightning Web Components | Hello World | Key Concepts

    Video in Lightning

    In this video, We are going to learn the new concept/technology that Salesforce has recently introduced to us. Below is the agenda that we are…

    Salesforce Lightning, How To Learn Salesforce Development, Easy Way To Learn Salesforce, How To Learn Salesforce Lightning, Salesforce Lightning Tutorial
    Victoria Jan 24, 2019
    2,227  Views
    Dreamforce To You 2020 - Algoworks

    Dreamforce To You 2020 - Algoworks

    Video in Salesforce Stories, Events

    The wait is over – Dreamforce will be going ahead in 2020! Salesforce has gone back to the drawing board and rebuilt Dreamforce 2020 for…

    Salesforce Integration, dreamforce, salesforce, Salesforce Event, Salesforce Video
    Algoworks Nov 5, 2020
    2,091  Views
    The future of Salesforce Lightning (according to Mike Rosenbaum)

    The future of Salesforce Lightning (according to Mike Rosenbaum)

    Video in Lightning

    We find out from Mike Rosenbaum (@mike945778) who is in charge of Salesforce Sales, Service & Lightning, the future of Salesforce Lightning at the London…

    Salesforce Lightning, Salesforce Lightning Experience, Salesforce Administrator, Salesforce Lightning Components, Salesforce Lightning Design System
    Hazel Feb 8, 2018
    2,173  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.