Home SALESFORCEAPEX Argument must be an object that implements Database.Batchable in Salesforce Batch Apex Class

Argument must be an object that implements Database.Batchable in Salesforce Batch Apex Class

Running below code to Developer Console and its throwing error,
ContactEmployeeNumberEmpty testCalc = new ContactEmployeeNumberEmpty();
Database.executebatch(testCalc);

Batch Apex Code:

[java]
global class ContactEmployeeNumberEmpty {

global Database.querylocator start(Database.BatchableContext BC) {
return Database.getQueryLocator([SELECT Id,
Name from Contact where Employee_Number__c = null]);
}

global void execute(Database.BatchableContext BC, list<Sales_Data__c> scope) {
}

global void finish(Database.BatchableContext BC) {
}
}
[/java]
Error:
Argument must be an object that implements Database.Batchable

Technical Solution:
This is because you are implementing the schedulable rather than batchable interface. So You can’t invoke executebatch on the Shedulable Apex Code.

Add in your apex class code like below (implements Database.Batchable<sObject>)

global class ContactEmployeeNumberEmpty implements Database.Batchable<sObject>

You may also like

Leave a Comment