1

I have a static callout which i want to schedule every 5 minutes. How would i approach this I have tried the following but the the incorrect signature error:

Callout

public class or_service { 
    @future(callout=true)
    public static void  getleads() {
        if(doCallout) {
          Http http = new Http();
          HttpRequest request = new HttpRequest();
          ..
        }
    }
}

Scheduler

public class or_scheduleLeads implements Schedulable {
    public void execute(SchedulableContext context) {
        System.abortJob(context.getTriggerId());
        String sch = '0 '+DateTime.now().addMinutes(5).minute()+' */1 ? * *';
        //System.schedule('Name', sch, class);
        System.schedule('or_scheduleLeads-'+DateTime.now(), sch, or_service.getleads());
    }
}
  • 1
    This sounds a little x-y ish to me. What are you trying to accomplish every five minutes? – David Reed Dec 28 '18 at 12:44
  • @DavidReed Pranay explained where my confusion was down below. Thanks – Thomas Dec 28 '18 at 13:14
3

The method signature of System.schedule is improper,

The correct signature is

schedule(jobName, cronExpression, schedulableClassInstance)

SO your code will be

public class or_scheduleLeads implements Schedulable {
    public void execute(SchedulableContext context) {
        System.abortJob(context.getTriggerId());
        String sch = '0 '+DateTime.now().addMinutes(5).minute()+' */1 ? * *';
        //Calling Future Methods
        or_service.getleads(); 
        System.schedule('or_scheduleLeads-'+DateTime.now(), sch, new or_scheduleLeads()));
    }
}

src: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_system.htm#apex_System_System_schedule

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.