You need to sign in to do that
Don't have an account?
Sainath Venkat
Batch apex to run at 12:10 AM everyday
Can anyone helpme out in scheduling a batch apex which need torun at 12:10 AM Everyday.
My batch apex code:
My batch apex code:
global class BatchImpliedConsentLead implements Database.Batchable<sObject> { global integer recordsProcessed = 0; global Database.QueryLocator start(Database.BatchableContext bc){ return Database.getQueryLocator('SELECT Id, Implied_Consent__c,Implied_Consent_Date__c,HasOptedOutOfEmail,CASL_Opt_In__c,CASL_Opt_In_Status__c, Implied_Consent_Expiry__c from Lead WHERE Implied_Consent__c != null AND Implied_Consent_Expiry__c != null'); } global void execute(Database.BatchableContext bc, List<Lead> scope){ for(lead l: scope){ //date d = l.Implied_Consent_Expiry__c.date(); if((l.Implied_Consent__c == true) && (l.Implied_Consent_Expiry__c.date() <= system.today()) ){ l.Implied_Consent_Date__c = null; l.Implied_Consent__c = false; l.HasOptedOutOfEmail = true; l.CASL_Opt_In__c = false; l.CASL_Opt_In_Status__c = 'Removed'; } update scope; } } global void finish(Database.BatchableContext bc){ system.debug(recordsProcessed +'records Processed'); AsyncApexJob job = [select Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems,CreatedBy.Email from AsyncApexJob where Id =: bc.getJobId()]; } }
All Answers
I have gone through your problem.
Schedule class:
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Sachin Arora