I want user of the managed package to be able to run a scheduled job that repeats every hour. The Scheduled Batch class is from the managed package and I'm having trouble accessing it when logged in as a user or subscriber in org where the package is installed. I've seen this question (scheduling a batch class to run every 15 min in managed package), but I'm wondering how to do it without the fancy UI. My end goal is that user/admin where package is installed can schedule it to run hourly and leave it to repeat indefinitely.
Stripped Batch Schedulable class: GetAllRecordsBatch
global with sharing class GetAllRecordsBatch implements Database.Batchable<sObject>, Database.AllowsCallouts, Database.Stateful, Schedulable {
public GetAllRecordsBatch() {
}
public Database.QueryLocator start(Database.BatchableContext BC) {
}
public void execute(Database.BatchableContext BC, List<Cognism_Campaign__c> scope) {
//logic
}
public void finish(Database.BatchableContext BC) {
}
global void execute(SchedulableContext sc){
GetAllRecordsBatch b = new GetAllRecordsBatch();
database.executebatch(b, 10);
}
}
When I try running it:
namespace.GetAllRecordsBatch refresher = new namespace.GetAllRecordsBatch();
// Seconds Minutes Hours Day_of_month Month Day_of_week Optional_year
String sch = '0 31 * * * ?';
String jobID = System.schedule('GetAllRecordsBatch2', sch, refresher);
I get an error message saying:
Method is not visible: void cogn.GetAllRecordsBatch.<init>()
I presume this part is needed to run the schedulable from UI? Because I can schedule it from the UI but that only support daily runs and I need it to run at least hourly:
global void execute(SchedulableContext sc){
I guess I'm missing a part or just need to make some method global, but not sure which one and why? Any help to understand this is appreciated.