+ Start a Discussion

Account Billing Address clean up


We are working on cleaning up of Account Billing Address.
How can we approach this project?


Go to setup > Admin manel > devleop > Apex Calss
Click on new

Pase Below code :
global class RemoveBillingInfo implements Database.Batchable<sObject>{

	global Database.QueryLocator start(Database.BatchableContext BC){
      String query = 'SELECT Name, BillingStreet, BillingCity, BillingState, BillingPostalCode,BillingCountry, BillingLatitude, BillingLongitude FROM Account' ;
	  return Database.getQueryLocator(query);
	global void execute(Database.BatchableContext BC, List<Account> AccountList){
		 for(Account act : AccountList){
			act.BillingStreet = '';
			act.BillingCity = '';
			act.BillingState = '';
			act.BillingPostalCode = '';
			act.BillingCountry = '';
			act.BillingLatitude = '';
			act.BillingLongitude = '';
		 update AccountList;
	global void finish(Database.BatchableContext BC){


Click on save.
Now go to your Name on top bar/ Navigation bar. Select Developer Console.

After opening developer console. Press CTRL + E
New small window will be opened.

paste following code in this.
RemoveBillingInfo obj = new RemoveBillingInfo();
Database.executeBatch(obj) ;
Click on execute button. and wait for some time becuase batch class takes some time to execute and process the reocrds becuase it is a bulk operation.

If above answer helps you to done the task. Please select answer as a solution.