Skip to Content

TheBlogReaders.com

Salesforce.com, PHP, MySQL, Javascript, Ajax, Htacces

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

Be First!
by March 26, 2013 APEX, SALESFORCE

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>

(1655)

Previous
Next

Leave a Reply