function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
civiccivic 

Edit the names of accounts

In PRODUCTION i need to edit the name all Accounts that being with "xx-" the edit will replace the leading "xx-" to "xxA-".

 Any help is appreciated

Best Answer chosen by Admin (Salesforce Developers) 
Ankit AroraAnkit Arora

One option is of Data Loader as suggested by Venu.

 

But if you don't have more than 10000 records with that name then you can use this script in system logs :

 

List<Account> accList = [select id,name from account where name like 'xx-%' limit 10000] ;
List<Account> accToUpdate = new List<Account>() ;
for(Account  a:  accList)
{
          a.Name = a.Name.replace('xx-' , 'xxA-') ;
          accToUpdate.add(a) ;
}

if(acctoUpdate.size() > 0)
     update acctoUpdate;

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

All Answers

BA_AdminBA_Admin

Extract all the Accounts thats start with xx with data loader and replace it with xxA and upload it back

Ankit AroraAnkit Arora

One option is of Data Loader as suggested by Venu.

 

But if you don't have more than 10000 records with that name then you can use this script in system logs :

 

List<Account> accList = [select id,name from account where name like 'xx-%' limit 10000] ;
List<Account> accToUpdate = new List<Account>() ;
for(Account  a:  accList)
{
          a.Name = a.Name.replace('xx-' , 'xxA-') ;
          accToUpdate.add(a) ;
}

if(acctoUpdate.size() > 0)
     update acctoUpdate;

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

This was selected as the best answer
civiccivic

Thanks.

I am trying to extract the file of accounts  which starts with xx- 

What does the query look like. I tried by export operation choosing account object and chose the Name field in the query and Name in the where clause and equals to in operation and XX- in the value. i

Pls help 

civiccivic

I will try that way and let u know Ankit.

 

Thx

BA_AdminBA_Admin

In the dataloader you can see the condition on top so add the condition such that name starts with xx so it extracts all the names which begins with xx

civiccivic

Ankit

 

Where should i write this script ? on object or where? I want to do this in production fyi.

I am new to this.

Pls let me know.

Cory CowgillCory Cowgill

You can access the System Log by clicking in upper right dropdown if your an admin.

 

Click your Name -> System Log.

 

This will open a popup which allows you to execute anonymous apex ("The Script" provided by Ankit).

civiccivic

Wonderful...Thx a ton.. It worked