---
schema_version: "1"
id: bcc2a6ecbe564463dad24c7e373b01a2388eb1c3b6149f2671c72787054669b9
title: FlexQueueItem
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/object_reference/sforce_api_objects_flexqueueitem.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_flexqueueitem.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0b7e872e1b4372a7fb200c7a850ce1e26b7798887bb7571dc5ff090b7c4ae57c
description: Represents an asynchronous Apex job in the Apex flex queue. Provides information about the job type and flex queue position of the AsyncApexJob. This object is available in API version 36.0 and later.
---
# FlexQueueItem

Represents an asynchronous Apex job in the Apex flex queue. Provides information about the job type and flex queue position of the AsyncApexJob. This object is available in API version 36.0 and later.

## Supported Calls

describeSObjects(), query()

## Special Access Rules

In API version 49.0 and later, users must have the View Setup and Configuration permission to access this object.

## Fields

| Field Name | Description |
| --- | --- |
| AsyncApexJobId | 
Type

reference

Properties

Filter, Group, Sort

Description

The ID of an [AsyncApexJob](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_asyncapexjob.htm#sforce_api_objects_asyncapexjob "Represents an individual Apex sharing recalculation job, a batch Apex job, a method with the future annotation, or a job that implements Queueable or Schedulable. Use this object to query Apex batch jobs in your organization.") that’s waiting in the flex queue.

This is a relationship field.

Relationship Name

AsyncApexJob

Relationship Type

Lookup

Refers To

AsyncApexJob



 |
| FlexQueueItemId | 

Type

string

Properties

Filter, Group, Nillable, Sort

Description

The primary key for this FlexQueueItem.



 |
| JobPosition | 

Type

int

Properties

Filter, Group, Sort

Description

The position in the flex queue of the waiting job. The highest-priority job in the queue is at position 0.



 |
| JobType | 

Type

picklist

Properties

Filter, Group, Restricted picklist, Sort

Description

The type of the job. Valid values are:

- ApexToken
- BatchApex
- BatchApexWorker
- Future
- Queueable
- ScheduledApex
- SharingRecalculation
- TestRequest
- TestWorker

Currently, queries are supported only on BatchApex jobs.





 |

## Usage

To find the position of an AsyncApexJob in the flex queue, query JobPosition. For example:

SELECT JobPosition FROM FlexQueueItem WHERE JobType = 'BatchApex' AND AsyncApexJobId = '707xx000000DABC'

To find the job at a given position, query AsyncApexJobId. For example:

SELECT AsyncApexJobId FROM FlexQueueItem WHERE JobType = 'BatchApex' AND JobPosition = '2'

To find all batch jobs in the flex queue, query JobType. To get other information about the jobs, include AsyncApexJob in your query. For example:

SELECT JobType, JobPosition, AsyncApexJob.ApexClass.Name, AsyncApexJob.CreatedDate,
    AsyncApexJob.CreatedById FROM FlexQueueItem WHERE JobType='BatchApex' AND
    AsyncApexJob.ApexClass.Name LIKE '%BatchAJob%' ORDER BY JobPosition DESC