Guest User

Untitled

a guest
Oct 18th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. global class CallQueueLeadChecker implements Schedulable {
  2. Datetime dtNow = system.now();
  3.  
  4. global void execute(SchedulableContext SC){
  5. checkLead();
  6. }
  7.  
  8. public void checkLead(){
  9. 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];
  10. for(Lead l : leadList){
  11. l.Active_Call_Queue2__c = TRUE;
  12. }
  13. update leadList;
  14. }
  15. }
  16.  
  17. System.schedule('Call Queue Checker 0', '0 0 * * * ?', new CallQueueLeadChecker());
  18. System.schedule('Call Queue Checker 15', '0 15 * * * ?', new CallQueueLeadChecker());
  19. System.schedule('Call Queue Checker 30', '0 30 * * * ?', new CallQueueLeadChecker());
  20. System.schedule('Call Queue Checker 45', '0 45 * * * ?', new CallQueueLeadChecker());
Add Comment
Please, Sign In to add comment