You need to sign in to do that
Don't have an account?

Need Help Scheduling Batch
Below is the Batch Job I have created. I am a litle fuzzy as to how to implement this in the shceduler. Can someone assist?
global class UpdateContactFlags implements Schedulable, Database.Batchable<sObject>{ public string query = 'SELECT Id, Contact.Id, Campaign.Fund_s__c, Campaign.Listing_Tactic__c, Status from CampaignMember'; global Database.Querylocator start(Database.BatchableContext BC) { return Database.getQueryLocator(query); } global void execute(SchedulableContext SC) { UpdateContactFlags ucfg = new UpdateContactFlags(); database.executebatch(ucfg, 100); } global void execute(Database.BatchableContext BC, List<sObject> scope) { Set<id> liContIds = new Set<id>(); for(sObject s : scope){ CampaignMember cm = (CampaignMember)s; if(cm.Campaign.Fund_s__c == 'FSIC' && cm.Campaign.IsActive == TRUE && cm.Campaign.Listing_Tactic__c == 'Major Market Roadshow') liContIds.add(cm.Contact.Id); } //query all the contact in a single query List<Contact> cont = new List<Contact>(); cont = [select id, Major_Market_Roadshows_Green__c from Contact where id in :liContIds and FSIC_Approved__c != NULL]; for ( Contact conts : cont) { conts.Major_Market_Roadshows_Green__c = 'Y' ; } if(cont.size() > 0) update cont; } global void finish(Database.BatchableContext BC){} }
Not really sure what I am missing.
Thank you in advance for the help.
Yes just schedule it there for your preferred time.
Thanks
All Answers
Call this batch apex from a schedular class
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm
And then schedule that apex classin Schedule Apex
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
So even though I have indicated that this is schedulable at the top of the class and have an execute funtion in the class, I still need a seperate class for it?
NO. I skipped the fact that you implemented both schedulable and batch class both here.
Than you just go forward and schedule this class. It is expected to work fine.
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
Ok so here is the stupid question. Where do I do that?
Found it! Ok now I feel like an idiot. Thank you for your guidance.
Yes just schedule it there for your preferred time.
Thanks