You need to sign in to do that
Don't have an account?
❤Code
batch apex error
Hi I am getting Constructor not defined: [MassDeleteRecords].<Constructor>(Integer) error while running the apex class from developer console. Please help .
Below is my code -
global class MassDeleteRecords implements Database.Batchable<sObject> {
global final string query;
global MassDeleteRecords (String q)
{
String query1 = q;
query = 'Select Id from Account where Round_Robin_ID__c =\'' + query1 + '\'';
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> scope){
List<Account> lsttoupdate = new List<Account>();
for(Account s : scope){
s.Description__c = 'Updated in Batch Apex';
lsttoupdate.add(s);
}
update lsttoupdate;
}
global void finish(Database.BatchableContext BC){
}
}
Developer console - I am running =
MassDeleteRecords b = new MassDeleteRecords(1);
Database.executeBatch(b);
Regards
Below is my code -
global class MassDeleteRecords implements Database.Batchable<sObject> {
global final string query;
global MassDeleteRecords (String q)
{
String query1 = q;
query = 'Select Id from Account where Round_Robin_ID__c =\'' + query1 + '\'';
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> scope){
List<Account> lsttoupdate = new List<Account>();
for(Account s : scope){
s.Description__c = 'Updated in Batch Apex';
lsttoupdate.add(s);
}
update lsttoupdate;
}
global void finish(Database.BatchableContext BC){
}
}
Developer console - I am running =
MassDeleteRecords b = new MassDeleteRecords(1);
Database.executeBatch(b);
Regards
In your class you have defined a constructor with strind as a parameter. When you create instance you are passing integer.
Add the Constructor with parameter as "Integer". Till then it will throw error.
Regards,
Manjunath
Thanks for the help . I have rectified my code and it is not throwing the error. I am able to run the batch, but the records are not getting updated. Can u please the above code and let me know where i am doing the mistake.
Thanks...