You need to sign in to do that
Don't have an account?
Tyler Harris
Error Implementing Database.batchable
I'm getting the following error in my batchable class. I want to pull all training records with an expiration date older than today and then ultimately mass update their Training Status to expired. I plan on making it schedulable.
I'm getting the following error:
BatchUpdateTraining: Class must implement the global interface method: Iterable<Training__c> start(Database.BatchableContext) from Database.Batchable<Training__c>
Apex:
I'm getting the following error:
BatchUpdateTraining: Class must implement the global interface method: Iterable<Training__c> start(Database.BatchableContext) from Database.Batchable<Training__c>
Apex:
global class BatchUpdateTraining implements Database.Batchable<Training__c>{ public String Query; public Database.QueryLocator start(Database.BatchableContext BC) { Query = 'SELECT id,Training_Status__c,Expiry_Date__c FROM Training__c WHERE Expiry_Date__c > Today'; return Database.getQueryLocator(Query); } public void execute(Database.BatchableContext BC, List<Training__c> scope) { for (Training__c ac : scope) { } update scope; } public void finish(Database.BatchableContext BC) { } }
Update your Code Like this, it will work.
global class BatchUpdateTraining implements Database.Batchable<sobject>{
public String Query;
public Database.QueryLocator start(Database.BatchableContext BC) {
Query = 'SELECT id,Training_Status__c,Expiry_Date__c FROM Training__c WHERE Expiry_Date__c > Today';
return Database.getQueryLocator(Query);
}
public void execute(Database.BatchableContext BC, List<Training__c> scope) {
for (Training__c ac : scope) {
}
update scope;
}
public void finish(Database.BatchableContext BC) { }
}
If this solves your Problem, Mark it as the Best Answer.
Thanks,
SFDC Beginner
All Answers
Update your Code Like this, it will work.
global class BatchUpdateTraining implements Database.Batchable<sobject>{
public String Query;
public Database.QueryLocator start(Database.BatchableContext BC) {
Query = 'SELECT id,Training_Status__c,Expiry_Date__c FROM Training__c WHERE Expiry_Date__c > Today';
return Database.getQueryLocator(Query);
}
public void execute(Database.BatchableContext BC, List<Training__c> scope) {
for (Training__c ac : scope) {
}
update scope;
}
public void finish(Database.BatchableContext BC) { }
}
If this solves your Problem, Mark it as the Best Answer.
Thanks,
SFDC Beginner