1

I am implementing the InstallHandler interface for a managed package which creates a scheduled job to run. A scheduled job is created when I install the package, with a status of Queued. However, the job never seems to run.

However, if I run the exact System.schedule command via anonymous Apex, the job actually gets created and runs properly. This makes me believe that the job creation and underlying code are working properly, but perhaps there is a permissions issue preventing the job from running. So far the only difference I can see is that the user is different for the two methods of creating the job. When installed by the managed package, the Submitted By name is the name of my package, but when I run via anonymous Apex the Submitted By name is my SysAdmin user.

Does anyone have an idea as to why the actual job never runs?

  • Has the installed package been copied down to a Sandbox by any chance? – bigassforce Sep 29 '15 at 18:13
  • Nope. I'm testing in a developer org, but not a sandbox. – Tim Gumto Sep 29 '15 at 20:17
  • 1
    Can you annotate without sharing on the InstallHandler and the Schedulable implementors, and then maybe confirm that the calculated start time is unaffected by user Locale settings? – bigassforce Sep 29 '15 at 20:28
  • Yep, this fixed it! I thought simply not having "with sharing" would cover it, but I was wrong. Thanks so much for the help @bigassforce! – Tim Gumto Sep 29 '15 at 21:25
  • 1
    @bigassforce Can you post an official answer for this? Sounds like it was the without sharing setting – Daniel Ballinger Apr 24 '18 at 21:54
1

The runtime privileges of the class may be ambiguous.

If you annotate without sharing on the InstallHandler and the Schedulable implementors, that would eliminate one source of possible problems.

After that, it would be a great post-mortem followup to find out which particular part of the install handler or scheduled job happened to be very sensitive to sharing.

| improve this answer | |

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.