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, 1 month 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, 1 month 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

    Migrating to Salesforce CRM

    All That You Need to Know About Migrating to Salesforce CRM

    Blog in Others

    There can be a number of reasons for companies to migrate from one CRM to another. While it indicates that a business is growing and…

    App Builder, Business, CRM, CRM Components, CRM Data Migration
    Grazitti Jun 14, 2022
    2,898  Views
    Salesforce Reports

    How To Export Salesforce Reports To Excel

    Blog in Salesforce integration

    Excel remains one of the leading tools for short and valuable reports. The training cost is low, and it’s easy to use. Salesforce works perfectly…

    API, Automated Exports, Bulky Reports, CSV File, CSV Formats
    Olena Prykhodko Jun 20, 2022
    5,188  Views
    Case Management

    Case Management: Email-To-Case | The Salesforce Developer Guide

    Blog in Others, Salesforce

    Case Management Case Management means gathering all the client/customer cases into one place and ensuring they go to the right person, for the resolved cases,…

    Brand Reputation, Case Details, Case Management, Case Origin, community
    Shweta Dec 15, 2020
    9,303  Views

    Popular Salesforce Videos

    Salesforce Development and Career Opportunities

    Salesforce Development and Career Opportunities

    Video in Salesforce Development

    Salesforce is the world’s #1 customer relationship management (CRM) platform. Salesforce allows sales reps to see everything about a customer in one place and provide…

    Salesforce Development, salesforce, Software Architecture, Salesforce Video, Customer Relationship Management
    Abhishek Jun 27, 2022
    2,095  Views
    Salesforce Customer 360 Data Manager

    Salesforce Customer 360 Data Manager

    Video in Others

    Salesforce Customer 360 Data Manager is a cross-cloud integration capability that allows Salesforce admins and developers to combine and reconcile customer data from their Salesforce…

    Salesforce Products, Salesforce Developer, Salesforce Integration, Salesforce Admin, Salesforce Data Storage
    Parul Feb 27, 2020
    3,908  Views
    Salesforce enthusiasts welcomes you to the Trailhead! Skill up for the future.

    Salesforce enthusiasts welcomes you to the Trailhead! Skill up for the future.

    Video in Others

    A trailhead is defined as an outdoor space that is designated by an entity responsible for administering or maintaining a trail to serve as an…

    Salesforce Trailhead, Salesforce Events, Dreamforce 2019, DF 19, Dreamforce 19
    Algoworks Nov 29, 2019
    1,749  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.