Reputation: 1
In Salesforce I am calling apex Batch from Apex class but it only calls the constructor of the batch and does not call start, execute and finish? What is going on?
I am calling the batch like this from a class.
ExportBatchClass EXPBTCH = new ExportBatchClass();
Database.executeBatch(EXPBTCH);
and the batch is :
global class ExportBatchClass implements Database.Batchable < Sobject > , Database.Stateful {
public String qryString;
global ExportBatchClass(){}
global ExportBatchClass(String qryString1){
qryString=qryString1;
System.debug('qryString======'+qryString);
} //END ExportBatchClass //
// Start Method
global Database.QueryLocator start(Database.BatchableContext BC){
qryString='SELECT Product__r.name From Products__c WHERE Name != null ORDER by Product__r.Name ASC';
system.debug('########## in START qryString = '+qryString);
return Database.getQueryLocator(qryString);
}
// Execute Logic
global void execute(Database.BatchableContext BC, List<Sobject> scope) {
for(Sobject s : scope)
{
Products__c pro=(Products__c)s;
productRelateListBatch.add(pro);
}
System.debug('productRelateListBatch======'+productRelateListBatch.size());
}
global void finish(Database.BatchableContext BC){
}
}
What am I missing?
Upvotes: 0
Views: 1984
Reputation: 1
Thank Q!! I resolved it.I just re-constructed it and the code now works fine.
Upvotes: 0