You need to sign in to do that
Don't have an account?
David Silva
How to pass an sObject to batch apex
global class DeleteJob implements Database.Batchable<sObject>{
global final Integer noOfYears;
sObject recordDeletionObject;
global DeleteJob(sObject newobject,Integer noOfYears)
{
recordDeletionObject= newObject;
this.noOfYears=noOfYears;
}
global Database.QueryLocator start(Database.BatchableContext BC)
{
return Database.getQueryLocator('hi');
}
global void execute(Database.BatchableContext BC, List<sObject> scope){
Delete scope;
}
global void finish(Database.BatchableContext BC){
}
}
global final Integer noOfYears;
sObject recordDeletionObject;
global DeleteJob(sObject newobject,Integer noOfYears)
{
recordDeletionObject= newObject;
this.noOfYears=noOfYears;
}
global Database.QueryLocator start(Database.BatchableContext BC)
{
return Database.getQueryLocator('hi');
}
global void execute(Database.BatchableContext BC, List<sObject> scope){
Delete scope;
}
global void finish(Database.BatchableContext BC){
}
}
Looks like you are trying to implement similar to this :
https://developer.salesforce.com/forums/?id=906F0000000AtLQIA0
You can try something like :