Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. global class ScheduledDispatcher Implements Schedulable{
  2.  
  3. public Interface IScheduleDispached{
  4. void execute(SchedulableContext sc);
  5. }
  6.  
  7. global void execute(SchedulableContext sc){
  8. Type targetType = Type.forName('{HANDLERNAME');
  9. if(targetType != null){
  10. IScheduleDispached obj = (IScheduleDispached)targetType.newInstance();
  11. obj.execute(sc);
  12. }
  13. }
  14.  
  15.  
  16. }
  17.  
  18. public class {HANDLERNAME} implements ScheduledDispatcher.IScheduleDispached {
  19.  
  20. public void execute(SchedulableContext sc)
  21. {
  22.  
  23. //Call your Future Method Here
  24.  
  25. }
  26.  
  27. }
  28.  
  29. public void runContactUpdates(list<Contact> triggernew)
  30. {
  31. if (System.isFuture() || System.isBatch())
  32. runContactUpdatesNow(triggernew);
  33. else
  34. runContactUpdatesFuture((new map<Id, Contact>(triggernew)).keyset());
  35. }
  36.  
  37. @Future
  38. public void runContactUpdatesFuture(set<Id> conids)
  39. {
  40.  
  41. runContactUpdatesNow([select Id, Name from Contact where Id in :conids]);
  42. }
  43.  
  44. public void runContactUpdatesNow(list<Contact> triggernew)
  45. {
  46. //do updates to contacts. Maybe update to database
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement