Newer Version Available

This content describes an older version of this product. View Latest

AsyncApexJob

Represents an individual Apex sharing recalculation job, a batch Apex job, a method with the future annotation, or a job that implements Queueable. Use this object to query Apex batch jobs in your organization.

Supported Calls

describeSObjects(), query(), retrieve()

Special Access Rules

The enableAsyncRequiresViewSetup field on the ApexSettings metadata type controls the activation of the critical update “Require View Setup permission to enqueue async Apex Jobs”. In API version 49.0 and later, when the field is set to true, users must have the View Setup and Configuration permission to access this object.

Fields

Field Name Details
ApexClassId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
The ID of the Apex class executing the job. Label is Class ID.
This is a relationship field.
Relationship Name
ApexClass
Relationship Type
Lookup
Refers To
ApexClass
CompletedDate
Type
dateTime
Properties
Filter, Nillable, Sort
Description
The date and time when the job was completed.
ExtendedStatus
Type
string
Properties
Filter, Group, Nillable, Sort
Description
If one or more errors occurred during the batch processing, this contains a short description of the first error. A more detailed description of that error, along with any subsequent errors, is emailed to the last user who modified the batch class. This field is available in API version 19.0 and later.
JobItemsProcessed
Type
int
Properties
Filter, Group, Sort
Description
Number of job items processed. Label is Batches Processed.
JobType
Type
picklist
Properties
Filter, Group, Restricted picklist, Sort
Description
The type of job being processed. Valid values are:
  • Future
  • SharingRecalculation
  • ScheduledApex
  • BatchApex
  • BatchApexWorker
  • TestRequest
  • TestWorker
  • ApexToken
  • Queueable
MethodName
Type
string
Properties
Filter, Group, Nillable, Sort
Description
The name of the Apex method being executed. Label is Apex Method.
NumberOfErrors
Type
int
Properties
Filter, Group, Nillable, Sort
Description
Total number of batches with a failure. A batch is considered transactional, so any unhandled exceptions constitute an entire failure of the batch. Label is Failures.
ParentJobId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
For batch Apex jobs that run using chunking implementation, multiple child jobs of type BatchApexWorker are created. Each of these child job records contain the job Id of the parent Apex job that started their execution. For batch Apex jobs that run using a non-chunking implementation, child jobs are not created.
Status
Type
picklist
Properties
Filter, Group, Restricted picklist, Sort
Description
The status of the job. Valid values are:
  • Holding1
  • Queued
  • Preparing
  • Processing
  • Aborted
  • Completed
  • Failed
1 This status applies to batch jobs in the Apex flex queue.
TotalJobItems
Type
int
Properties
Filter, Group, Nillable, Sort
Description
Total number of batches processed. Each batch contains a set of records. Label is Total Batches.

Usage

Use this object to query Apex batch jobs in your organization.