---
schema_version: "1"
id: a81a6e12236a2cc148b1b7096cf9d5ed68d3d8c349b2224426df825c3624d402
title: FinalizerContext Interface
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_interface_System_FinalizerContext.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_System_FinalizerContext.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 3b5e105c89d8a37d3bb64bd45db836c7fed0e53657dcfda177e1c914206501b4
description: "Represents the parameter type of the execute method in a class that implements the Finalizer interface. This interface is implemented internally by Apex. The System.FinalizerContext interface contains four methods: getAsyncApexJobId, getRequestId, getResult, and getException. An instance of System.FinalizerContext is injected by the Apex runtime engine as an argument to the Finalizer.execute method. Returns the ID of the Queueable job for which this finalizer is defined.Returns the exception with which the Queueable job failed when getResult is UNHANDLED_EXCEPTION, null otherwise.Returns the request ID that can be correlated with Event Monitoring logs. To correlate the request with the AsyncApexJob table, use the getAsyncApexJobId method instead. The Queueable job and the Finalizer execution share the same request ID.Returns the System.ParentJobResult enum, which represents the result of the parent asynchronous Apex Queueable job to which the finalizer is attached. The enum takes these values: SUCCESS, UNHANDLED_EXCEPTION."
---
# FinalizerContext Interface

Represents the parameter type of the execute method in a class that implements the Finalizer interface. This interface is implemented internally by Apex. The System.FinalizerContext interface contains four methods: getAsyncApexJobId, getRequestId, getResult, and getException. An instance of System.FinalizerContext is injected by the Apex runtime engine as an argument to the Finalizer.execute method.

## Namespace

[System](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_System.htm "The System namespace provides classes and methods for core Apex functionality.")

- **[FinalizerContext Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_System_FinalizerContext.htm#apex_System_FinalizerContext_methods)**

## FinalizerContext Methods

The following are methods for FinalizerContext.

- **[getAsyncApexJobId()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_System_FinalizerContext.htm#apex_System_FinalizerContext_getAsyncApexJobId)**  
    Returns the ID of the Queueable job for which this finalizer is defined.
- **[getException()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_System_FinalizerContext.htm#apex_System_FinalizerContext_getException)**  
    Returns the exception with which the Queueable job failed when getResult is UNHANDLED\_EXCEPTION, null otherwise.
- **[getRequestId()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_System_FinalizerContext.htm#apex_System_FinalizerContext_getRequestId)**  
    Returns the request ID that can be correlated with Event Monitoring logs. To correlate the request with the AsyncApexJob table, use the getAsyncApexJobId method instead. The Queueable job and the Finalizer execution share the same request ID.
- **[getResult()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_System_FinalizerContext.htm#apex_System_FinalizerContext_getResult)**  
    Returns the System.ParentJobResult enum, which represents the result of the parent asynchronous Apex Queueable job to which the finalizer is attached. The enum takes these values: SUCCESS, UNHANDLED\_EXCEPTION.

### getAsyncApexJobId()

Returns the ID of the Queueable job for which this finalizer is defined.

#### Signature

public Id getAsyncApexJobId()

#### Return Value

Type: [Id](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_id.htm#apex_methods_system_id "Contains methods for the ID primitive data type.")

### getException()

Returns the exception with which the Queueable job failed when getResult is UNHANDLED\_EXCEPTION, null otherwise.

#### Signature

public Exception getException()

#### Return Value

Type: Exception

### getRequestId()

Returns the request ID that can be correlated with Event Monitoring logs. To correlate the request with the AsyncApexJob table, use the getAsyncApexJobId method instead. The Queueable job and the Finalizer execution share the same request ID.

#### Signature

public String getRequestId()

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### getResult()

Returns the System.ParentJobResult enum, which represents the result of the parent asynchronous Apex Queueable job to which the finalizer is attached. The enum takes these values: SUCCESS, UNHANDLED\_EXCEPTION.

#### Signature

public System.ParentJobResult getResult()

#### Return Value

Type: [System.ParentJobResult](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_enum_System_ParentJobResult.htm "Specifies the success or exception status of the parent Queueable job to which a Transaction Finalizer is attached.")