Description
Recently, I faced an interesting situation in one of my Salesforce environments. A batch class that was scheduled to run daily was not being executed as expected. When I checked in Apex Jobs, the batch class was showing a status of "Queued", and I was left wondering if it was actually running in the backend or not.
Step 1: Checking the Batch Job in Apex Jobs
To verify the status of my batch, I used the following SOQL query:
SELECT ApexClassId,
ApexClass.Name,
Id,
JobItemsProcessed,
JobType,
Status,
NumberOfErrors,
MethodName,
CreatedDate,
CompletedDate
FROM AsyncApexJob
WHERE ApexClass.Name = 'Your_Batch_Class_Name'
This query gave me the details, but the status still showed as Queued.
Step 2: Why Does the Status Stay Queued?
Here’s the catch - by design, scheduled apex will always remain in the "Queued" status until the job has an end date.
- If your job is scheduled indefinitely, it will always stay in the Queued state because Salesforce treats it as continuously scheduled.
- To avoid confusion, it’s recommended to always provide both a Start Date and an End Date while scheduling your batch jobs.
Without the end date, you might feel like the job is stuck, when in fact it’s simply the way Salesforce handles indefinite schedules.
Step 3: How to Verify If the Batch is Actually Executing
If you want to confirm that your scheduled batch is actually running, use this SOQL on CronTrigger:
SELECT FIELDS(ALL)
FROM CronTrigger
WHERE CronJobDetail.Name = 'Your_Batch_Class_Name'
This query provides insights such as:
- The scheduled time of your batch job
- The end time for execution on that day
This way, you can be confident that your job is not really stuck but is being executed as per the defined schedule.
Key Takeaway
These issues may look simple but can easily eat up a whole day if you don’t know the underlying reason.
- Always provide Start Date and End Date when scheduling batches.
- Use CronTrigger SOQL to validate execution details instead of relying only on AsyncApexJob.
With this understanding, you’ll save yourself hours of debugging the next time you face a “Queued” batch job in Salesforce.
Learn Data Cloud with Real World Example

0 Comments