Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global class ScheduledDispatcher Implements Schedulable{
- public Interface IScheduleDispached{
- void execute(SchedulableContext sc);
- }
- global void execute(SchedulableContext sc){
- Type targetType = Type.forName('{HANDLERNAME');
- if(targetType != null){
- IScheduleDispached obj = (IScheduleDispached)targetType.newInstance();
- obj.execute(sc);
- }
- }
- }
- public class {HANDLERNAME} implements ScheduledDispatcher.IScheduleDispached {
- public void execute(SchedulableContext sc)
- {
- //Call your Future Method Here
- }
- }
- public void runContactUpdates(list<Contact> triggernew)
- {
- if (System.isFuture() || System.isBatch())
- runContactUpdatesNow(triggernew);
- else
- runContactUpdatesFuture((new map<Id, Contact>(triggernew)).keyset());
- }
- @Future
- public void runContactUpdatesFuture(set<Id> conids)
- {
- runContactUpdatesNow([select Id, Name from Contact where Id in :conids]);
- }
- public void runContactUpdatesNow(list<Contact> triggernew)
- {
- //do updates to contacts. Maybe update to database
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement