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
priya bhawna shettypriya bhawna shetty 

Account field updated related scenario

Hello guys

hope all doing well

i have a small scenario pls help me out.

I have 10000 Accounts in my organisation and my question is , i want to update country field to 'USA'  to all my 10000 Accounts at a time..how do i achieve this...

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
digamber.prasaddigamber.prasad

Hi,

 

If you have only 10000 accounts, please run below code using Developer Console >> Execute Anonymous and run the below code:-

for(List<Account> lstAccount : [Select Id, Country from Account]){
	for(Integer i=0; i<lstAccount.size(); i++){
		lstAccount[i].Country = 'USA';
	}
	update lstAccount;
}

 However, the other solution which is best is using DataLoader.

 

Please let me know if you have any question about above.

 

Happy to help you!

 

 

 

All Answers

digamber.prasaddigamber.prasad

Hi,

 

If you have only 10000 accounts, please run below code using Developer Console >> Execute Anonymous and run the below code:-

for(List<Account> lstAccount : [Select Id, Country from Account]){
	for(Integer i=0; i<lstAccount.size(); i++){
		lstAccount[i].Country = 'USA';
	}
	update lstAccount;
}

 However, the other solution which is best is using DataLoader.

 

Please let me know if you have any question about above.

 

Happy to help you!

 

 

 

This was selected as the best answer
priya bhawna shettypriya bhawna shetty

hi

can i solve it through trigger,judge me ,if i am wrong with this trigger

trigger acctupdate on Account(before insert,before update)

{

 for (Account a:trigger.new)

 {

  a.state='USA';

 }

}

digamber.prasaddigamber.prasad

Hi,

 

You can use trigger for this. But what about historical data? If you want to use trigger, still you have to false update historical data to make sure every record is updated.

 

Let me know if you have any specific question about this.

 

Happy to help you!