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 

I am Sakthivel Madesh, a certified Salesforce Advanced Developer & Administrator working on Salesforce Technology since 2011. I am currently working in Techforce Services as Sr. Salesforce Developer. I have worked on multiple technologies Like PHP, Java, Salesforce, I am very passionate about Salesforce and to earn 15x Salesforce Certification. I love Trailhead for learning Salesforce Skill and Become a Trailhead 5x Ranger too. I Love to Learn & Share my Salesforce knowledge to Salesforce Learners/Beginner using My Blog and Salesforce Community.

Leave a Reply

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

*