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

    Email Relay in Salesforce

    How to Setup Email Relay in Salesforce - Learn Here

    Blog in Salesforce Admin

    In this blog, we got to know How to setup Email Relay in Salesforce. Reviewing the Current Setup of our Salesforce ORG Login in your…

    Configure Button, Email, Email Domain Filter, Email Relay, Email Relay Connection
    shreya yadav Jul 13, 2022
    10,432  Views

    Macros – One Of The Most "Severely Underused" Salesforce Feature

    Blog in Salesforce Implementation

    Salesforce has a number of features. Some of them are useful and mostly used by the Salesforce users and developers, while a few features are…

    Features of Salesforce, Salesforce Consulting Services, Salesforce Feature, Salesforce Macros
    Louis Aug 3, 2017
    14,838  Views
    Salesforce Marketing Cloud

    How To Get Benefits From Salesforce Marketing Cloud?

    Blog in Others, Salesforce Consultant

    Salesforce Marketing cloud earlier known as Exact Target provides digital marketing and analytical software and services. Salesforce blazed a trail by creating marketing cloud and…

    Audience Builder, Channels, Content Builder, Digital Marketing, Journey Builder
    Natalya Sep 24, 2018
    3,486  Views

    Popular Salesforce Videos

    5 Facts You Didn't Know About Salesforce

    5 Facts You Didn't Know About Salesforce

    Video in Salesforce Stories

    In this video, we have tried to share some amazing facts about Salesforce, the world leader in CRM, that you didn't know about so that…

    Salesforce Integration, Salesforce Implementation, salesforce, salesforce knowledge, CRM
    Algoworks Sep 7, 2020
    2,257  Views
    Parent to Child SOQL vs Map | Salesforce Training in Apex

    Parent to Child SOQL vs Map | Salesforce Training in Apex

    Video in Salesforce Training

    Watch this video to learn all about Parent to Child SOQL vs Map. Do let us know in the comment section if you have any…

    Salesforce Training, Salesforce Tutorial, Apex, SOQL, Salesforce Video
    Abhishek Nov 25, 2021
    2,966  Views
    How to Crack Salesforce Platform Developer I Exam in 2021?

    How to Crack Salesforce Platform Developer I Exam in 2021?

    Video in Salesforce Certifications

    Salesforce Platform Developer I Certification Training ensures that you master the concepts and components of application development on the Salesforce platform. Watch this video and…

    Salesforce Training, Salesforce Certification, Salesforce Developer, salesforce platform, Salesforce Video
    Neha Yadav May 6, 2021
    3,460  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.