Is there any way to change or set the crontrigger ownerId? I started an Apex Job in a Post Install Script and the ownerId is the installed package. I need change it or abort the job and start it again with the System Administratior id.

Thanks, Airton.


The only way to set the OwnerId is to be logged in as that user.

Per the CronTrigger Docs only query is supported and you cannot use DML for this object.

The simplest way to do this is to first log in as the right user and just delete the job from setup (setup->monitor->scheduled jobs), and then reschedule (setup->develop->apex classes, click 'Schedule Apex').

You could do this with apex as well if you have the scheduled job id

Id jobId = '00000000000000';
String jobName = 'JobName';
String cronString = '0 0 0 3 9 ? 2022';
system.schedule(jobName, cronString, new SchedulableClass());
| improve this answer | |
  • Hi Ralph, thank you. Is there a way to set the OwnerId when I sechedule the job? – Airton Gessner Mar 28 '13 at 13:03
  • 1
    The only way to set the OwnerId is to be logged in as that user. – Ralph Callaway Mar 28 '13 at 17:14

What did you try?

Here's how to set/use the scheduler ... http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm

| improve this answer | |
  • I tried to update the Owner ID, but it's not possible. – Airton Gessner Mar 27 '13 at 17:07
  • you need to delete the record and and reschedule it as you. – PartOfTheOhana Mar 27 '13 at 21:05
  • Yes, but I need to do it in a Script, cause the schedule is created through the Post Install Script and I need to set the user as the administrator user. – Airton Gessner Mar 28 '13 at 12:09

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.