Skip to main content

Action Configuration

At the heart of the framework is the Trigger Action (seven20__Trigger_Action__mdt) metadata type, this metadata type acts as the primary control centre for both packaged and custom trigger actions. Each record represents a single trigger action and its associated invocation configuration. Below is an overview of a trigger action record:

Field LabelAPI NameTypeDescription
LabelMasterLabelText(40)A user friendly label for the trigger action
NameDeveloperNameText(40)The API name of the trigger action
Apex Class Nameseven20__Apex_Class_Name__cText(40)The name of the Apex class that implements the trigger action
Namespaceseven20__Namespace__cText(40)The namespace prefix of the Apex class that implements the trigger action, if applicable. For no-namespace orgs, this should be blank
Trigger Objectseven20__Trigger_Object__cMetadata Relationship(Entity Definition)A lookup to the object that the trigger action should be invoked for
Trigger Object (Special)seven20__Trigger_Object_Special__cPicklistA picklist of objects which aren't supported by the entity definition which can be triggered from, e.g. User or Task
Trigger Contextseven20__Trigger_Context__cPicklistThe context in which the trigger action should be invoked, these values match the TriggerOperation Enum values
Invoke Orderseven20__Invoke_Order__cNumber(3, 2)The order in which the trigger action should be invoked, relative to other actions with the same object and context. Lower numbers are invoked first
Is Activeseven20__Is_Active__cCheckboxWhether the trigger action is active or not. If this is unchecked, the trigger action will not be invoked
warning

While Invoke Order supports decimal invoke orders, these should be avoided unless absolutely necessary.

note

If an action supports multiple context types, multiple records are required, one for each context.

Disabling actions declaratively

Actions can be disabled as required by unchecking the Is Active checkbox on the trigger action record. This is useful for disabling actions on a temporary basis, such as when performing data migrations, or if critical issues are discovered in a piece of recently deployed code.

Additionally, if the need arises, actions can be globally disabled. This is achieved by enabling the Seven20 Configuration setting which has a developer name of Disable_All_Triggers.

Disabling actions programmatically

Actions can also be disabled via apex on a temporary basis if the need requires. The seven20.TriggerHandler class has several exposed methods to achieve this, they are:

void setGlobalDisabledStatus(Boolean disabled) - Used to set the global trigger action disable flag. Default value is based on the value of the Disable_All_Triggers configuration setting.

Boolean getGlobalDisabledStatus() - Returns the current status of the global trigger action disable flag.

void setTriggerActionDisabledStatus(Id actionId, Boolean disabled) - Used to disable, or re-enable, a specific trigger action for the current transaction. Does not override the global disabled flag, or the record's Is Active flag.

Boolean getTriggerActionDisabledStatus(Id actionId) - Returns whether a specific action has been explicitly disabled through the setTriggerActionDisabledStatus method.

info

The effects of the above methods only persist for the current transaction.