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?