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

    Creating a Salesforce Platform Event With Lightning Flow

    Blog in Lightning, Salesforce

    Platform events are used to integrate Salesforce business operations with external sources via the exchange of real-time event data. Platform events are safe and easy…

    Apps, Communications Platform, custom object, Customize your Platform, data
    Apphienz Aug 16, 2021
    6,117  Views

    Salesforce Editions and its Types

    Blog in Others

    Salesforce Edition Nowadays emerging companies move their business to Salesforce or switch to Salesforce CRM depending upon their requirements.so the choose edition for their business.…

    CRM Functionality, Custom Dashboard, Developer Sandbox, Salesforce Custom Reports, Salesforce Developer Console
    Marziya Feb 21, 2020
    4,731  Views
    Validation Rules in Salesforce

    Defining Validation Rules in Salesforce

    Blog in Salesforce

    Validation Rule With this post, we will learn about Validation Rule, which are criteria defined to validate the data entered by the user when creating…

    Campaign Member, Case Milestone, Contact Objects, data, Error Condition
    NAVDITA DAHIYA Nov 11, 2022
    2,562  Views

    Popular Salesforce Videos

    Salesforce Security – An Encryption Guide For The Paranoid

    Salesforce Security – An Encryption Guide For The Paranoid

    Video in Salesforce Security, Salesforce Implementation

    If you are using Salesforce, you would be having a lot of data stored in Salesforce objects. Some of it would even be sensitive enough…

    Salesforce Development, Salesforce Apex, Salesforce Security, Salesforce Implementation, Salesforce Data Management
    Algoworks Feb 21, 2018
    2,460  Views
    Tips to Crack the Salesforce Administrator Certification Exam in One Go

    Tips to Crack the Salesforce Administrator Certification Exam in One Go

    Video in Salesforce Certifications, Salesforce Admin

    Do you want to become Salesforce administrator certified? So in this video Shrey has shared the important topics to crack the Salesforce Administrator Exam. Following…

    Salesforce Training, Salesforce Tutorial, Salesforce Certification, Salesforce Administrator, salesforce
    S2 Feb 25, 2022
    3,051  Views
    What is Validation Rule in Salesforce?

    What is Validation Rule in Salesforce?

    Video in Salesforce Training

    Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. A…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Data, Salesforce Learning
    CRS Apr 12, 2022
    1,614  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.