You need to sign in to do that
Don't have an account?

How do run the batch class in annonoymus apex
Can anybody help me in executing the below batch class using annonomous apex
global class batchUpdateAccounts implements Database.Batchable<sObject>,Database.Stateful{
global Database.QueryLocator start(Database.BatchableContext bc){
return database.getQuerylocator('select id,Category__c,Family__c from Account');
}
global void execute(Database.BatchableContext bc, List<SObject> scope) {
List<Account> accs = (List<Account>)scope;
List<Account> accsToUpdate = new List<Account>();
List<Global_families__c> gfslst = new List<Global_families__c>();
gfslst = [select Is_Global__c, Name from Global_families__c];
for(Account acunts : accs){
for(Global_families__c lstglobal: gfslst ){
if(acunts.Family__c == lstglobal.Name && lstglobal.Is_Global__c == TRUE){
Acunts.Family__c = 'Global';
accsToUpdate.add(acunts);
}
}
}
update accsToUpdate;
}
global void finish(Database.BatchableContext bc){
}
}
I have tried to run the below code but it throws me an error saying incorrect signature
batchUpdateAccounts objTest = new batchUpdateAccountst();
Database.executebatch(objTest);
Try this out -)
batchUpdateAccounts objTest = new batchUpdateAccounts();
Database.executebatch(objTest,200);