Orphaned CronJobDetail records breaking Scheduled Jobs in Salesforce Summer ’17

For the second year in a row, we’re lucky to be among the first to discover a problem with the summer release of Salesforce, and have that problem become a known issue. Last year LightningLockerServices Critical Update.

What’s the problem?

I’m witnessing an issue in a sandbox we recently refreshed. We’re running a vendor product on top of Salesforce (this issue will still affect you, even if you’re not running the same app). Within the app’s admin panel, I’m trying to start something called ‘Scheduler’, which corresponds to a Salesforce scheduled apex job. However, this job never starts, and no error is gets displayed.

So, something doesn’t work, and we’ve got no leads to follow. That’s where the fun begins!

What we’ve discovered is an issue with Summer ’17 when it comes to refreshing a sandbox copy of an org (this is now a known issue). Specifically, a sandbox refresh no longer copies over CronTrigger rows for scheduled apex jobs, but associated CronJobDetail rows still get copied. Therefore, when you refresh a sandbox, if you have configured scheduled apex jobs in your production org, you’re going to end up with orphaned CronJobDetail rows.

How do all these things work together?

Ok, let’s break this down a bit. In Salesforce, scheduled Apex jobs are stored as CronTrigger records. You can see a list of your scheduled apex jobs in Developer Console by running the following query:

One of the columns returned is CronJobDetailId. This is a reference to the CronJobDetail sObject. CronJobDetail records describe the CronTrigger records. You can query these records in Developer Console to see those details as well:

Because of this issue, we have CronJobDetail records that have been copied over, but the parent CronTrigger records haven’t been.  The Name field on CronJobDetail must be unique, and since we’re trying to create two records with the same Name, the whole process fails.

How do we solve this?

Clients cannot do anything to rectify this. It’s up to Salesforce to solve this issue, and the issue is currently under their review. Until then, you must open a case with Salesforce support and ask them to delete the orphaned CronJobDetail rows.

Author: Matt

Matthew is a highly accomplished and award-winning programmer who is well versed in a variety of the hottest technologies powering today's most successful companies. With 11+ years of experience, Matthew has done it all: from the most rudimentary tasks to complex implementations of entire applications, CRMs, and pieces thereof. Today he spends his time mastering salesforce.com administration, development, and implementation as he mediates between stakeholders and project owners to successfully interface a complex company in a complex industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.