2

Scenario:

Documentation on my org has a gap regarding a scheduled batch apex. This batch code updates a related list on the lead object. This List and process is call ‘nearby references’ and ‘find nearby references’ respectively.

I have found what class it is firing by correlating run times between a cronjob and AsyncApexJob records. Which I did using SOQL queries:

SELECT CronExpression, EndTime, CronJobDetailId, CronJobDetail.Name, NextFireTime FROM CronTrigger WHERE CronJobDetail.JobType = '7' AND CronJobDetail.name = 'Weekly Nearby References' 

The WHERE filters came second once I found the cronjobdetail named 'Weekly Nearby References'

I used the Cron Expression from this to search asyncapexjobs for a record that matched that time.

SELECT id, Startime, ApexClassID, CompletedDate, ExtendedStatus, JobType, MethodName, Status FROM AsyncApexJob WHERE CompletedDate > 2019-01-06T00:00:00.000+0000 AND CompletedDate < 2019-01-07T00:00:00.000+0000 AND apexClassId = '01pC000000XXXXXX' and jobtype != 'BatchApexWorker'

Again WHERE filters of classid and jobtype came later as I zeroed in. Allowing me to see “findNearbyReferences” class was the one firing at that time.

Problem

I believe it was scheduled via system.schedule()

I need to find the class that was called to schedule this batch. But I can’t seem to find what scheduled the cron job or connects it to the asyncapexjob record.

Essentially; how Do I find what apex a cronjob Triggers?

2
  • Hi Ryan, welcome to SFSE! Please take a moment to scroll through the tour and read How to Ask. Your title is essentially backwards from what you seem to be trying to find out. Please note that the format here is question and answer. But you do not actually ask anything above. Please try to structure your post such that you have a sentence which ends in a question mark. Another thing which often trips up those new to the format: good questions will be those you actually care about the answer to. Not Does anyone know X? but rather How do I X?.
    – Adrian Larson
    Jan 8, 2019 at 23:11
  • Thanks Adrian You actually have helped me out a few times now so thank you a ton. I wrote this late yesterday I will work on that! Jan 9, 2019 at 13:32

1 Answer 1

5

You can't know what process kicked off a scheduled job. Any scheduled job could be kicked off from the UI or Execute Anonymous, in addition to any classes which might actually do the scheduling.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .