1

Within our unlocked package, we have implemented a class TimesheetWindowScheduler that implements the Schedulable interface. This class is responsible for executing specific tasks.

public with sharing class TimesheetWindowScheduler implements Schedulable {
    public void execute(SchedulableContext ctx) {
       //... do something
    }

Ideally, we aim to trigger the scheduling of this job automatically upon the installation or upgrade of our package

TimesheetWindowScheduler m = new TimesheetWindowScheduler();
System.schedule(TIMESHEET_WINDOW_SCHEDULER, schedule, m);

Without open developer console, do we have any other way to do that?

8
  • This might be helpful resource - salesforce.stackexchange.com/questions/32607/…
    – kurunve
    Dec 12, 2023 at 9:39
  • 1
    ah, InstallHandler for managed package, but I'd like run on unlocked package
    – vctqs1
    Dec 12, 2023 at 9:50
  • ouch, my mistake, I apologise for the inconvenience. In case of unlocked package -- this might help - salesforce.stackexchange.com/questions/236826/…
    – kurunve
    Dec 12, 2023 at 10:16
  • ah no, it's okay. but in my case, I need to run to trigger Apex Scheduler. But It can't able to access Package's Class from sfdx force:source:deploy
    – vctqs1
    Dec 12, 2023 at 10:45
  • 2
    You can run anonymous apex through the sf/sfdx CLI, so the two lines you have could be sent for anonymous execution by a second CLI command in your "install script". Remember to include any namespace, if you have namespaced the unlocked package.
    – Phil W
    Dec 12, 2023 at 11:22

0

You must log in to answer this question.