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 › 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, 2 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!

    • 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, 2 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

    application solution

    Popular Salesforce Blogs

    Salesforce Philanthropy Cloud: Putting Generosity into Action

    Blog in Salesforce Cloud Platform, Salesforce Products

    Salesforce, the number 1 CRM platform in the world, has historically maintained a strong philanthropic policy. Since its inception, it laid the foundations that would…

    Artificial Intelligence, Business Grants, Businesses and Employees, Campaigns, Connected Platform
    SkyPlanner Dec 20, 2022
    1,911  Views
    Salesforce Consulting

    Is the Salesforce Consulting Company Any Good? Ten Ways You Can be Certain

    Blog in Salesforce Consultant

    Salesforce Customer Relationship Management, or CRM, is the best platform for a service cloud offering globally. Salesforce is championing and leading CRM adoption around the…

    Best CRM Platform, Boosting Sales, Business Applications, Business Goals, Business Needs
    nakul singh May 31, 2021
    3,799  Views

    Balancing Human & Ai-Powered Customer Service

    Blog in AI and ML

    Customer service is the vital relationship between a company and its customers, since it helps to keep and improve the value of those customers. By…

    Artificial Intelligence, Automated messaging, Automation, Balancing human and AI-powered customer service, Banking Industry
    Twistellar Jul 18, 2023
    1,301  Views

    Popular Salesforce Videos

    Salesforce Security and Sharing Model Demystified

    Salesforce Security and Sharing Model Demystified

    Video in Salesforce Security

    The Salesforce Sharing and Security Model has undergone numerous enhancements and offers many features to help you configure it to meet the privacy requirements your…

    Salesforce Security, Salesforce Sales Cloud, Salesforce Service Cloud, Salesforce Developer, Salesforce Apps
    Prafull Mar 22, 2018
    1,973  Views
    Developer Preview Live - Release Readiness Live, Winter '22 | Salesforce

    Developer Preview Live - Release Readiness Live, Winter '22 | Salesforce

    Video in

    The Winter ’22 release is packed full of features to help developers solve key business problems fast. Join us to learn from Product Managers and…

    Salesforce Training, Salesforce Tutorial, salesforce, Apex, Salesforce Video
    Jogender Oct 4, 2021
    1,729  Views
    How To Dominate Peak Shopping Seasons with Salesforce Commerce Cloud?

    How To Dominate Peak Shopping Seasons with Salesforce Commerce Cloud?

    Video in Others

    Peak shopping seasons can make or break a business. In our latest webinar, we break down the power of Salesforce Commerce Cloud and how it…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Tutorials, Salesforce Video
    Cyntexa Nov 16, 2023
    843  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.