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:

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) {
}
}

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>

Written by 

Salesforce MVP | Lightning Champion | 16x Salesforce Certified | Application Architect | 6x Trailhead Ranger | Techforce Services | Australia

Leave a Reply

Your email address will not be published. Required fields are marked *

*