---
schema_version: "1"
id: 8b259147c01d211ca85835f8225f83b0c0673b64479074fec103e6706d2218d6
title: ApexTrigger
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_tooling/tooling_api_objects_apextrigger.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_apextrigger.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 35bd8d2246f95912dd9621330ee8be47e4000f027d71c744bbdb74a45e5ab348
description: Represents the saved copy of an Apex trigger. ApexTrigger uses the cached version of the class unless one is unavailable. Available from API version 28.0 or later.
---
# ApexTrigger

Represents the saved copy of an Apex trigger. ApexTrigger uses the cached version of the class unless one is unavailable. Available from API version 28.0 or later.

To edit, save, or compile Apex triggers, use [ApexTriggerMember](https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_apextriggermember.htm "Represents the working copy of an Apex trigger for editing, saving, or compiling in a MetadataContainer.").

## Supported SOAP API Calls

create(), delete(), describeSObjects(), query(), retrieve(), update(), upsert()

## Supported REST API HTTP Methods

Query, GET, POST, PATCH, DELETE

## Fields

| Field Name | Details |
| --- | --- |
| ApiVersion | 
Type

double

Properties

Create, Filter, Sort, Update

Description

The API version for this trigger. Every trigger has an API version specified at creation.



 |
| Body | 

Type

string

Properties

Create, Nillable, Update

Description

The Apex trigger definition. Limit: 1 million characters.



 |
| BodyCrc | 

Type

double

Properties

Create, Defaulted on create, Filter, Nillable, Sort, Update

Description

The CRC (cyclic redundancy check) of the class or trigger file.



 |
| EntityDefinitionId | 

Type

string

Properties

Filter, Group, Nillable, Sort

Description

The Id of the EntityDefinition object associated with this object.



 |
| IsValid | 

Type

boolean

Properties

Create, Defaulted on create, Filter, Group, Sort, Update

Description

Indicates whether any dependent metadata has changed since the trigger was last compiled (true) or not (false).



 |
| LengthWithoutComments | 

Type

int

Properties

Create, Filter, Group, Sort, Update

Description

Length of the trigger without comments.



 |
| ManageableState | 

Type

ManageableState enumerated list

Properties

Filter, Group, Nillable, Restricted picklist, Sort

Description

Indicates the manageable state of the specified component that is contained in a package:

- beta
- deleted
- deprecated
- deprecatedEditable
- installed
- installedEditable
- released
- unmanaged





 |
| Metadata | 

Type

ApexTriggerMetadata

Properties

None

Description

An object that describes the version, status, and packaged versions of the corresponding Apex trigger.

Query this field only if the query result contains no more than one record. Otherwise, an error is returned. If more than one record exists, use multiple queries to retrieve the records. This limit protects performance.



 |
| Status | 

Type

picklist

Properties

Create, Filter, Group, Restricted picklist, Sort, Update

Description

The status of the Apex trigger. The following string values are valid:

- Active—The trigger is active.
- Inactive—The trigger is inactive, but not deleted.
- Deleted—The trigger is marked for deletion. This status is useful for managed packages, because it allows a class to be deleted when a managed package is updated.

![Note](https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/images/icon_note.png)

#### Note

Apex triggers cannot be deactivated using Tooling API. You can deactivate Apex triggers using Metadata API. Consider using custom metadata records and include logic in your trigger to bypass trigger configuration logic. For more information, see the [Metadata API Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.264.0.api_meta.meta/api_meta/ "HTML (New Window)").















 |
| UsageAfterDelete | 

Type

boolean

Properties

Create, Filter, Update

Description

Specifies whether the trigger is an after delete trigger (true) or not (false).



 |
| UsageAfterInsert | 

Type

boolean

Properties

Create, Filter, Update

Description

Specifies whether the trigger is an after insert trigger (true) or not (false).



 |
| UsageAfterUndelete | 

Type

boolean

Properties

Create, Filter, Update

Description

Specifies whether the trigger is an after undelete trigger (true) or not (false).



 |
| UsageAfterUpdate | 

Type

boolean

Properties

Create, Filter, Update

Description

Specifies whether the trigger is an after update trigger (true) or not (false).



 |
| UsageBeforeDelete | 

Type

boolean

Properties

Create, Filter, Update

Description

Specifies whether the trigger is a before delete trigger (true) or not (false).



 |
| UsageBeforeInsert | 

Type

boolean

Properties

Create, Filter, Update

Description

Specifies whether the trigger is an before insert trigger (true) or not (false).



 |
| UsageBeforeUpdate | 

Type

boolean

Properties

Create, Filter, Update

Description

Specifies whether the trigger is an before update trigger (true) or not (false).



 |
| UsageIsBulk | 

Type

boolean

Properties

Create, Filter, Update

Description

Specifies whether the trigger is defined as a bulk trigger (true) or not (false).



 |

## Usage

To retrieve information about an Apex trigger, create an ApexTrigger object that references it. For example code, see [SOAP Calls](https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/intro_soap_overview.htm).

To edit, save, or compile Apex triggers, use [ApexTriggerMember](https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_apextriggermember.htm "Represents the working copy of an Apex trigger for editing, saving, or compiling in a MetadataContainer.").

Although Apex classes and triggers have the Create and Update field properties, a runtime exception occurs if you try to create, update, or delete them using the API. Instead, use the Salesforce Extensions for Visual Studio Code or the Ant Migration Tool to create or update Apex classes or triggers. Apex classes and triggers can’t be created, edited, or deleted in a production org. See [Deploying Apex](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/apex_deploying.htm).