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

    salesforce pdo partner

    Salesforce PDO Partner Program 2021: A Guide

    Blog in AppExchange, Salesforce

    Salesforce AppExchange has been a huge hit across its 15-year lifespan and is the key differentiator for Salesforce when it comes to the global CRM…

    APIs, App Idea, AppExchange Security Review, AppExchange Startups, Application
    Algoworks Jun 4, 2021
    2,320  Views

    Case Study: Salesforce Pharma Order Management System Transformation

    Blog in Salesforce

    Key steps are taken to optimize operational efficiency and Salesforce integration in the pharmaceutical industry. Managing orders across diverse markets presents challenges that demand innovative…

    Business Operations, Business Process, Case Study, Code Expansion, CRM
    Triple Innovations Dec 19, 2023
    1,479  Views
    Sharing Rules in Salesforce

    The Definitive Guide for Sharing Rules in Salesforce

    Blog in Others, Salesforce

    One of Salesforce's key objectives is to integrate marketing, sales, commerce, service, and IT departments regardless of geographic location via its customer service component known…

    Commerce, Company's Personalized Expectations, CRM Platform, Customer 360, Customer Relationship Management
    Cymetrix Jul 20, 2021
    2,877  Views

    Popular Salesforce Videos

    Create a Multi-page App Using LWC OSS | Salesforce Lightning

    Create a Multi-page App Using LWC OSS | Salesforce Lightning

    Video in Lightning, Salesforce Apps

    The default LWC OSS project created using the create-lwc-app tool lets you create a single-page application. But did you know that by slightly modifying the…

    Salesforce Training, Salesforce Tutorial, Salesforce Lightning, Salesforce Apps, Salesforce Video
    Jogender Jun 16, 2021
    3,275  Views
    Salesforce Developers Innovate From Anywhere

    Salesforce Developers Innovate From Anywhere

    Video in Salesforce Stories, Salesforce Development

    Hear from Developer Trailblazers to learn how they’ve been innovating from anywhere and making magic happen for their users with Salesforce. With Salesforce, Developers can…

    Salesforce Tutorial, salesforce, Salesforce Trailhead, Salesforce Developers, Salesforce Learning
    Abhishek Oct 1, 2021
    2,306  Views
    Attribute Setup for Skill based Routing in Salesforce

    Attribute Setup for Skill based Routing in Salesforce

    Video in Salesforce Training

    This video is 3rd Part of the Omnichannel Series. Implementation of Attribute set up skill-based routing with the demo. Do let us know in the…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Video, Salesforce Learning
    Pooja Nov 26, 2021
    2,378  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.