Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v5
with:
ref: ${{ github.ref }}
fetch-depth: 0

- uses: actions/setup-node@v1
- uses: actions/setup-node@v6
with:
node-version: ">=14"
check-latest: true

- name: Install Salesforce CLI + Scanner
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
packageId: ${{ steps.create.outputs.packageId }}
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- uses: actions/setup-node@v4
- uses: actions/setup-node@v6
with:
node-version: ">=20"

Expand Down
40 changes: 31 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Apex Trigger Actions Framework

#### [Unlocked Package Installation (Production)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04tKY000000QQ0RYAW)
#### [Unlocked Package Installation (Production)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04tKY000000R0yHYAS)

#### [Unlocked Package Installation (Sandbox)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04tKY000000QQ0RYAW)
#### [Unlocked Package Installation (Sandbox)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04tKY000000R0yHYAS)

---

Expand Down Expand Up @@ -242,29 +242,35 @@ You can bypass all actions on an sObject as well as specific Apex or Flow action

#### Bypass from Apex

To bypass from Apex, use the static `bypass(String name)` method in the `TriggerBase`, `MetadataTriggerHandler`, or `TriggerActionFlow` classes.
The framework provides compile-safe bypass methods that accept type references.

**Bypass sObjects using Schema.sObjectType:**

```java
public void updateAccountsNoTrigger(List<Account> accountsToUpdate) {
TriggerBase.bypass('Account');
TriggerBase.bypass(Schema.Account.SObjectType);
update accountsToUpdate;
TriggerBase.clearBypass('Account');
TriggerBase.clearBypass(Schema.Account.SObjectType);
}
```

**Bypass Apex classes using System.Type:**

```java
public void insertOpportunitiesNoRules(List<Opportunity> opportunitiesToInsert) {
MetadataTriggerHandler.bypass('TA_Opportunity_StageInsertRules');
MetadataTriggerHandler.bypass(TA_Opportunity_StageInsertRules.class);
insert opportunitiesToInsert;
MetadataTriggerHandler.clearBypass('TA_Opportunity_StageInsertRules');
MetadataTriggerHandler.clearBypass(TA_Opportunity_StageInsertRules.class);
}
```

**Bypass Flows using Flow.Interview:**

```java
public void updateContactsNoFlow(List<Contacts> contactsToUpdate) {
TriggerActionFlow.bypass('Contact_Flow');
TriggerActionFlow.bypass(Flow.Interview.Contact_Flow.class);
update contactsToUpdate;
TriggerActionFlow.clearBypass('Contact_Flow');
TriggerActionFlow.clearBypass(Flow.Interview.Contact_Flow.class);
}
```

Expand Down Expand Up @@ -615,3 +621,19 @@ public void execute(FinalizerHandler.Context context) {
}
}
```

---

## Documentation Generation

This project uses [ApexDocs](https://github.com/cparra/apexdocs) to generate documentation from Apex class comments. To generate the documentation:

```bash
npx @cparra/apexdocs markdown \
-s trigger-actions-framework \
-t docs \
-p public \
-g docsify
```

The generated documentation will be available in the `docs/` directory and can be viewed using any static site generator or served directly.
59 changes: 59 additions & 0 deletions docs/trigger-actions-framework/MetadataTriggerHandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,65 @@ True if the Trigger Action is bypassed, false otherwise.

---

### `bypass(actionType)`

Bypass the execution of a Trigger Action.

#### Signature
```apex
public static void bypass(System.Type actionType)
```

#### Parameters
| Name | Type | Description |
|------|------|-------------|
| actionType | System.Type | The Type of the Trigger Action to bypass. |

#### Return Type
**void**

---

### `clearBypass(actionType)`

Clear the bypass for a Trigger Action.

#### Signature
```apex
public static void clearBypass(System.Type actionType)
```

#### Parameters
| Name | Type | Description |
|------|------|-------------|
| actionType | System.Type | The Type of the Trigger Action to clear the bypass for. |

#### Return Type
**void**

---

### `isBypassed(actionType)`

Check if a Trigger Action is bypassed.

#### Signature
```apex
public static Boolean isBypassed(System.Type actionType)
```

#### Parameters
| Name | Type | Description |
|------|------|-------------|
| actionType | System.Type | The Type of the Trigger Action to check. |

#### Return Type
**Boolean**

True if the Trigger Action is bypassed, false otherwise.

---

### `clearAllBypasses()`

Clear all bypasses for Trigger Actions.
Expand Down
68 changes: 68 additions & 0 deletions docs/trigger-actions-framework/TriggerActionFlow.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,74 @@ public static Boolean isBypassed(String flowName)

---

### `bypass(flowType)`

This method bypasses the execution of the Flow for the specified list of records.

#### Signature
```apex
public static void bypass(System.Type flowType)
```

#### Parameters
| Name | Type | Description |
|------|------|-------------|
| flowType | System.Type | The Type of the Flow to bypass (e.g., Flow.Interview.MyFlow.class). |

#### Return Type
**void**

#### Throws
IllegalArgumentException: if the type does not represent a Flow.

---

### `clearBypass(flowType)`

This method clears the bypass for the specified list of records.

#### Signature
```apex
public static void clearBypass(System.Type flowType)
```

#### Parameters
| Name | Type | Description |
|------|------|-------------|
| flowType | System.Type | The Type of the Flow to clear the bypass for (e.g., Flow.Interview.MyFlow.class). |

#### Return Type
**void**

#### Throws
IllegalArgumentException: if the type does not represent a Flow.

---

### `isBypassed(flowType)`

This method checks if the Flow is bypassed for the specified list of records.

#### Signature
```apex
public static Boolean isBypassed(System.Type flowType)
```

#### Parameters
| Name | Type | Description |
|------|------|-------------|
| flowType | System.Type | The Type of the Flow to check the bypass for (e.g., Flow.Interview.MyFlow.class). |

#### Return Type
**Boolean**

,[object Object], if the Flow is bypassed for the specified list of records, ,[object Object], otherwise.

#### Throws
IllegalArgumentException: if the type does not represent a Flow.

---

### `clearAllBypasses()`

This method clears all bypasses for all Flows.
Expand Down
74 changes: 74 additions & 0 deletions docs/trigger-actions-framework/TriggerActionFlowChangeEvent.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,80 @@ public static Boolean isBypassed(String flowName)

---

### `bypass(flowType)`

*Inherited*

This method bypasses the execution of the Flow for the specified list of records.

#### Signature
```apex
public static void bypass(System.Type flowType)
```

#### Parameters
| Name | Type | Description |
|------|------|-------------|
| flowType | System.Type | The Type of the Flow to bypass (e.g., Flow.Interview.MyFlow.class). |

#### Return Type
**void**

#### Throws
IllegalArgumentException: if the type does not represent a Flow.

---

### `clearBypass(flowType)`

*Inherited*

This method clears the bypass for the specified list of records.

#### Signature
```apex
public static void clearBypass(System.Type flowType)
```

#### Parameters
| Name | Type | Description |
|------|------|-------------|
| flowType | System.Type | The Type of the Flow to clear the bypass for (e.g., Flow.Interview.MyFlow.class). |

#### Return Type
**void**

#### Throws
IllegalArgumentException: if the type does not represent a Flow.

---

### `isBypassed(flowType)`

*Inherited*

This method checks if the Flow is bypassed for the specified list of records.

#### Signature
```apex
public static Boolean isBypassed(System.Type flowType)
```

#### Parameters
| Name | Type | Description |
|------|------|-------------|
| flowType | System.Type | The Type of the Flow to check the bypass for (e.g., Flow.Interview.MyFlow.class). |

#### Return Type
**Boolean**

,[object Object], if the Flow is bypassed for the specified list of records, ,[object Object], otherwise.

#### Throws
IllegalArgumentException: if the type does not represent a Flow.

---

### `clearAllBypasses()`

*Inherited*
Expand Down
59 changes: 59 additions & 0 deletions docs/trigger-actions-framework/TriggerBase.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,65 @@ True if the object is bypassed, false otherwise.

---

### `bypass(sObjectType)`

This method bypasses the execution of the specified object.

#### Signature
```apex
public static void bypass(Schema.sObjectType sObjectType)
```

#### Parameters
| Name | Type | Description |
|------|------|-------------|
| sObjectType | Schema.sObjectType | The sObjectType of the object to bypass. |

#### Return Type
**void**

---

### `clearBypass(sObjectType)`

This method clears the bypass for the specified object.

#### Signature
```apex
public static void clearBypass(Schema.sObjectType sObjectType)
```

#### Parameters
| Name | Type | Description |
|------|------|-------------|
| sObjectType | Schema.sObjectType | The sObjectType of the object to clear the bypass for. |

#### Return Type
**void**

---

### `isBypassed(sObjectType)`

This method checks if the specified object is bypassed.

#### Signature
```apex
public static Boolean isBypassed(Schema.sObjectType sObjectType)
```

#### Parameters
| Name | Type | Description |
|------|------|-------------|
| sObjectType | Schema.sObjectType | The sObjectType of the object to check the bypass for. |

#### Return Type
**Boolean**

True if the object is bypassed, false otherwise.

---

### `clearAllBypasses()`

This method clears all bypasses.
Expand Down
3 changes: 2 additions & 1 deletion sfdx-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"Trigger Actions Framework@0.3.1-6": "04tKY000000PdZ9YAK",
"Trigger Actions Framework@0.3.1-7": "04tKY000000PdZJYA0",
"Trigger Actions Framework@0.3.2": "04tKY000000PdZOYA0",
"Trigger Actions Framework@0.3.3": "04tKY000000QQ0RYAW"
"Trigger Actions Framework@0.3.3": "04tKY000000QQ0RYAW",
"Trigger Actions Framework@0.3.4-1": "04tKY000000R0yHYAS"
}
}
Loading