Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. public with sharing class LeadTriggerHandler
  2. {
  3. @testVisible
  4. static Boolean bypassTrigger = false;
  5.  
  6. @testVisible
  7. static Set<Id> recentlyAssignedOwners = null;
  8.  
  9. final List<Lead> newLeads;
  10. final Map<Id, Lead> oldmap;
  11. public LeadTriggerHandler(List<Lead> newLeads, Map<Id, Lead> oldmap)
  12. {for (Lead a : newLeads)
  13. if(a.Marketing_List_CEC__c == false)
  14. continue;
  15. {
  16. this.newLeads = newLeads;
  17. this.oldmap = oldmap;
  18. }
  19. }
  20. public void beforeInsert()
  21. {
  22. if(bypassTrigger) return;
  23. List<Lead> leadsToRoute = Select.Records.all(
  24. new List<Select.Filter>{
  25. LeadRouter.isHeavyCivilLead(),
  26. LeadRouter.trialSource().notx(),
  27. LeadRouter.createdByMarketoBeforeInsert(),
  28. LeadRouter.hasQuantmSource().notx()
  29. }
  30. ).filter(newLeads);
  31. LeadRouter.routeToDealer(leadsToRoute);
  32. if (Test.isRunningTest()) {
  33. recentlyAssignedOwners = pluck.ids(Lead.OwnerId, leadsToRoute);
  34. }
  35. }
  36.  
  37. public void beforeUpdate()
  38. {
  39. if (bypassTrigger) return;
  40. LeadRouter.routeToDealer(
  41. Select.Records.any(new List<Select.Filter> {
  42. LeadRouter.trialSentToCustomer(),
  43. LeadRouter.shouldReassign()
  44. }
  45. ).filter(newLeads, oldmap));
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement