I'm new to the development side with no real development background in any language. So I wrote this batch class, and I can't quite figure out how to implement the proper syntax for the constructor.
This is what the constructor requires:
MD_PersonatorBatch(String q, Boolean updateContact, Boolean processAll)
This is what i've got so far:
global class listwareWeekly implements Database.Batchable<sObject>
{
global Database.QueryLocator start(Database.BatchableContext BC)
{
String query = ('SELECT Id, MailingCountry, Email, Melissa_Email_Result_Codes__c FROM Contact WHERE isDeleted = False LIMIT 100');
return Database.getQueryLocator((query)true, false); //I know this is wrong. I've tried a few different things, but this is where i'm at.
}
global void execute(Database.BatchableContext BC, List<Contact> scope)
{
MDPERSONATOR.MD_PersonatorBatch bb = new MDPERSONATOR.MD_PersonatorBatch();
Database.executeBatch(bb);
}
global void finish(Database.BatchableContext BC)
{
}
}
Any assistance would be greatly appreciated!
Best Answer
Based on what you've got here:
and
it sounds like you're not really trying to write a batch class; you're trying to call a batch class that is supplied by a managed package.
If that is the case, you don't need to write this code at all. For a one-time invocation of the batch, you'll just need to run Anonymous Apex from your Developer Console:
With a batch class, you generally won't need the
LIMIT 100
clause - batch classes are designed to process thousands of records in batches. However, you'll really just need to consult the documentation for your managed package for any unique limitations of this functionality.Edit: based on your comment
You don't need to write a batch class; you need to write a
Schedulable
class, whoseexecute()
message does something like what I show above. TheSchedulable
interface allows you to schedule regular runs.A
LIMIT
clause on a SOQL query does not affect the batch size; it controls the total number of records retrieved. The batch size is controlled by the second argument toDatabase.executeBatch()
, which I've updated above.