Skip to content

Commit

Permalink
docs(ApexDox): andFinally documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dschach committed Feb 27, 2023
1 parent d026a91 commit b4ce9d8
Show file tree
Hide file tree
Showing 22 changed files with 531 additions and 1,298 deletions.
4 changes: 1 addition & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run updateHighlight
npm run precommit
git add docs/*.html
npm run precommit
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
{
"files": "*.html",
"options": { "useTabs": false, "tabWidth": 2 }
"options": { "parser": "html", "useTabs": false, "tabWidth": 2 }
},
{
"files": "*.css",
Expand Down
20 changes: 11 additions & 9 deletions DEPLOY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

1. Set up your environment. Follow the steps in the [Quick Start: Lightning Web Components](https://trailhead.salesforce.com/content/learn/projects/quick-start-lightning-web-components/) Trailhead project. The steps include:

- Enable Dev Hub in your org or Trailhead Playground
- Install [Visual Studio Code](https://developer.salesforce.com/tools/vscode/en/getting-started/install/#visual-studio-code)
- Install [Salesforce CLI](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm)
- Install the [Visual Studio Code Salesforce extensions](https://developer.salesforce.com/tools/vscode/en/getting-started/install/#salesforce-extensions-for-visual-studio-code)
<ul>
<li>Enable Dev Hub in your org or Trailhead Playground</li>
<li>Install <a target="_blank" href="https://developer.salesforce.com/tools/vscode/en/getting-started/install/#visual-studio-code">Visual Studio Code</a></li>
<li>Install <a target="_blank" href="https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm">Salesforce CLI</a></li>
<li>Install the <a target="_blank" href="https://developer.salesforce.com/tools/vscode/en/getting-started/install/#salesforce-extensions-for-visual-studio-code">Visual Studio Code Salesforce extensions</a></li>
</ul>

1. If you haven't already done so, authorize your hub org and provide it with an alias (**myhuborg** in the command below):

```
```plaintext
sfdx auth:web:login --setdefaultdevhubusername --setalias myhuborg
```

1. Clone the duplicatehandling repository:

```
```plaintext
git clone https://github.com/dschach/salesforce-trigger-framework
cd salesforce-trigger-framework
```
Expand All @@ -32,20 +34,20 @@

1. Create a scratch org and provide it with an alias (**triggerHandler** in the command below):

```
```plaintext
sf org create scratch --set-default --definition-file config/project-scratch-def.json --alias triggerHandler
```

This will create a new scratch org and install all metadata in this repository

2. Push the app to your scratch org:

```
```plaintext
sf deploy metadata
```

3. Open the scratch org:

```
```plaintext
sf org open
```
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,30 @@

# Salesforce Trigger Framework

- [Salesforce Trigger Framework](#salesforce-trigger-framework)
- [Credit](#credit)
- [Documentation](#documentation)
- [Overview](#overview)
- [Usage](#usage)
- [Trigger Handler](#trigger-handler)
- [Trigger](#trigger)
- [Cool Stuff](#cool-stuff)
- [Bypass API](#bypass-api)
- [Check Bypass Status](#check-bypass-status)
- [Global Bypass](#global-bypass)
- [Set Bypass](#set-bypass)
- [Max Loop Count](#max-loop-count)
- [Debug Statements](#debug-statements)
- [Universal Action](#universal-action)
- [Overridable Methods](#overridable-methods)

## Credit

Based on Kevin O'Hara's famous framework [sfdc-trigger-framework](https://github.com/kevinohara80/sfdc-trigger-framework)

## Documentation

[Class Documentation](https://dschach.github.io/salesforce-trigger-framework/index.html)
[Class Documentation](https://dschach.github.io/salesforce-trigger-framework/TriggerHandler.html)

## Overview

Expand Down Expand Up @@ -123,7 +140,6 @@ public class OpportunityTriggerHandler extends TriggerHandler {
acc.Name = 'With Trigger';
update acc; /* will invoke the AccountTriggerHandler */
}
}
Expand Down Expand Up @@ -212,7 +228,7 @@ There are two methods that will show additional information.

`TriggerHandler.showLimits()` will debug Apex query and DML limits when the trigger handler has completed.

`TriggerHandler.showDebug()` will show trigger entry and exit, but only during Apex testing. This is to ensure org performance.
`TriggerHandler.showDebug()` will show trigger entry and exit in debug logs. Use sparingly, as it will decrease org performance.

To use one or both of these, add them to the trigger:
```apex
Expand All @@ -224,6 +240,10 @@ AccountTriggerHandler.showDebug(false);
```
or just put them in your Apex code before and after DML statements.

### Universal Action

Version 1.1 adds a new method: `andFinally()` which can contain actions that should happen in every trigger context, after all other actions. Credit to James Simone for this idea. As he writes, "runs after every context - can be used to easily implement something like apex-rollup!" ([The Joys of Apex](https://www.jamessimone.net/blog/joys-of-apex/lightweight-trigger-handler/))

## Overridable Methods

Here are all of the methods that you can override. All of the context possibilities are supported.
Expand All @@ -235,3 +255,4 @@ Here are all of the methods that you can override. All of the context possibilit
- `afterUpdate()`
- `afterDelete()`
- `afterUndelete()`
- `andFinally()`
17 changes: 9 additions & 8 deletions apexdox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,28 @@ engine:
title: Salesforce Trigger Handler code documentation
subtitle: Documentation for <a target="_blank" rel="noopener noreferrer" href="https://github.com/dschach/salesforce-trigger-framework">Trigger Framework</a>
sortOrder: alpha
cleanDir: false # keep prettier config file
cleanDir: true # keep prettier config file
showTOCSnippets: true
scope:
- public
- private
- protected
- testMethod
homePagePath: "${workspaceFolder}/doc-assets/homePage.html"
#pages:
# - "${workspaceFolder}/documentation/Funny.html"
pages:
- "${workspaceFolder}/doc-assets/files/deploy.html"
assets:
- "${workspaceFolder}/doc-assets/logo.png"
- "${workspaceFolder}/doc-assets/favicon.png"
- "${workspaceFolder}/doc-assets/icon.png"
- "${workspaceFolder}/doc-assets/highlight.css"
- "${workspaceFolder}/doc-assets/styling.css"
- "${workspaceFolder}/doc-assets/index.css"
- "${workspaceFolder}/doc-assets/highlight.js"
- "${workspaceFolder}/doc-assets/icon.png"
- "${workspaceFolder}/doc-assets/index.css"
- "${workspaceFolder}/doc-assets/index.js"
- "${workspaceFolder}/doc-assets/logo.png"
- "${workspaceFolder}/doc-assets/styling.css"
#- "${workspaceFolder}/doc-assets/files/sampletriggerhandlerhome.html"
port: 9090
docblock:
alignItems: true
spacious: true
omitDescriptionTag: true
omitDescriptionTag: false
65 changes: 65 additions & 0 deletions doc-assets/files/deploy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<link href="assets/styling.css" rel="stylesheet" />
<h1 id="installing-the-app-using-a-scratch-org">Installing the app using a Scratch Org</h1>
<ol>
<li>
Set up your environment. Follow the steps in the
<a href="https://trailhead.salesforce.com/content/learn/projects/quick-start-lightning-web-components/">Quick Start: Lightning Web Components</a> Trailhead project. The steps
include:
</li>
</ol>
<ul>
<li>Enable Dev Hub in your org or Trailhead Playground</li>
<li>Install <a target="_blank" href="https://developer.salesforce.com/tools/vscode/en/getting-started/install/#visual-studio-code">Visual Studio Code</a></li>
<li>Install <a target="_blank" href="https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm">Salesforce CLI</a></li>
<li>
Install the
<a target="_blank" href="https://developer.salesforce.com/tools/vscode/en/getting-started/install/#salesforce-extensions-for-visual-studio-code"
>Visual Studio Code Salesforce extensions</a
>
</li>
</ul>

<ol>
<li>
<p>If you haven&#39;t already done so, authorize your hub org and provide it with an alias (<strong>myhuborg</strong> in the command below):</p>
<pre><code class="language-plaintext">sfdx auth:web:login --setdefaultdevhubusername --setalias myhuborg
</code></pre>
</li>
<li>
<p>Clone the duplicatehandling repository:</p>
<pre><code class="language-plaintext">git clone https://github.com/dschach/salesforce-trigger-framework
cd salesforce-trigger-framework
</code></pre>
</li>
<li>
<p>Create your scratch org</p>
<ul>
<li>
<p>Using the included script From the VSCode command line, run <a href="scripts/orginit.sh">orginit script</a></p>
<pre><code class="language-plaintext">. scripts/orginit.sh
</code></pre>
</li>
<li>
<p>Using CLI manually</p>
<ol>
<li>
<p>Create a scratch org and provide it with an alias (<strong>triggerHandler</strong> in the command below):</p>
<pre><code class="language-plaintext">sf org create scratch --set-default --definition-file config/project-scratch-def.json --alias triggerHandler
</code></pre>
<p>This will create a new scratch org and install all metadata in this repository</p>
</li>
<li>
<p>Push the app to your scratch org:</p>
<pre><code class="language-plaintext">sf deploy metadata
</code></pre>
</li>
<li>
<p>Open the scratch org:</p>
<pre><code class="language-plaintext">sf org open
</code></pre>
</li>
</ol>
</li>
</ul>
</li>
</ol>
File renamed without changes.
Loading

0 comments on commit b4ce9d8

Please sign in to comment.