Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global class CallQueueLeadChecker implements Schedulable {
- Datetime dtNow = system.now();
- global void execute(SchedulableContext SC){
- checkLead();
- }
- public void checkLead(){
- List<Lead> leadList = [SELECT Id,Active_Call_Queue2__c FROM Lead WHERE Active_Call_Queue2__c = FALSE AND No_Call_Queue__c = FALSE AND (NOT Phone LIKE '%wrong%') AND (NOT Phone LIKE '%invalid%') AND (NOT MobilePhone LIKE '%wrong%') AND (NOT MobilePhone LIKE '%invalid%') AND (Phone !=null OR MobilePhone !=null) AND (Status='Open' OR Status = 'Contacted') AND Picked_By__c=null AND Is_Picked__c = FALSE AND (Last_Open_Timestamp_Formula__c <: dtNow OR Last_Open_Timestamp_Formula__c = NULL) ORDER BY Hubspot_Score__c DESC NULLS LAST LIMIT 200];
- for(Lead l : leadList){
- l.Active_Call_Queue2__c = TRUE;
- }
- update leadList;
- }
- }
- System.schedule('Call Queue Checker 0', '0 0 * * * ?', new CallQueueLeadChecker());
- System.schedule('Call Queue Checker 15', '0 15 * * * ?', new CallQueueLeadChecker());
- System.schedule('Call Queue Checker 30', '0 30 * * * ?', new CallQueueLeadChecker());
- System.schedule('Call Queue Checker 45', '0 45 * * * ?', new CallQueueLeadChecker());
Add Comment
Please, Sign In to add comment