docs: update documentation for multi-copy Authorization to Release feature

requirements.md (v1.1):
- Add FR-006: multi-copy Authorization to Release Information requirement
- Add US-005: user story for requesting multiple copies
- Add future enhancement item for admin-configurable multi-copy forms
- Add change log table

design.md (v1.1):
- Add section 2.4: full design description of the multi-copy feature
  including configuration constant, new flow elements table, updated
  flow path diagram, and Apex expansion logic
- Update component diagram and Request inner class to include
  authReleaseFormCopies
- Add change log table

DEPLOYMENT_AND_TESTING.md (v1.1):
- Update Screen Flow setup instructions to document authReleaseFormCopies
  input parameter and built-in dialog behaviour
- Add 'Updating the Multi-Copy Template Name' section with step-by-step
  instructions for updating the Apex constant and Flow decision condition
- Update class/flow reference list
- Add change log table

api-reference.md:
- Bump version header to 1.1
This commit is contained in:
Paul Huliganga 2026-03-11 16:24:04 -04:00
parent 9b355b997e
commit 86e7d2fb62
4 changed files with 193 additions and 8 deletions

View File

@ -218,6 +218,37 @@ Apex Code Coverage: 92%
---
## Updating the Multi-Copy Template Name
The "Authorization to Release Information" template name is stored in **two places**. If this template is ever renamed, update both:
### 1. Apex constant — `DocusignCompositeEnvelopeBuilder.cls`
```apex
// Line ~30 in DocusignCompositeEnvelopeBuilder.cls
private static final String MULTI_COPY_TEMPLATE_NAME = 'Authorization to Release Information';
```
Change the string value to match the new template name (partial match is fine — the query uses `LIKE '%<name>%'`).
### 2. Flow decision — `Docusign_Envelope_Templates_V3.flow-meta.xml`
In the `Does_Row_Contain_Auth_Release` decision node, update the `Contains` condition value:
```xml
<conditions>
<leftValueReference>Scan_For_Auth_Release_Template.Name</leftValueReference>
<operator>Contains</operator>
<rightValue>
<stringValue>Authorization to Release Information</stringValue> <!-- update here -->
</rightValue>
</conditions>
```
After editing the XML, redeploy the flow to your org.
---
## Updating Template IDs After Sandbox Refresh
After a sandbox refresh, Docusign template IDs may become stale and need updating with the correct demo/sandbox template IDs.
@ -326,12 +357,15 @@ After successful deployment, configure your Salesforce org:
- **Salesforce Record ID** — {!Record.Id}
- **Language** — en or es
- **Email Subject** — Optional custom subject
- **Authorization to Release Form Copies** — Number of copies (13) for the Authorization to Release Information template; populated by the `authReleaseFormCopies` flow variable (defaults to 1)
4. Output Variables:
- **Envelope ID** — Unique Docusign envelope ID
- **Success** — Boolean (true/false)
- **Error Message** — Error details if creation failed
5. Save and test the flow
> **Multi-copy dialog**: If you are using `Docusign_Envelope_Templates_V3`, the flow automatically detects when "Authorization to Release Information" is selected and displays a radio-button screen asking for 1, 2, or 3 copies before sending. No additional Flow configuration is required for this feature.
---
## Troubleshooting
@ -397,7 +431,8 @@ sf apex run test --target-org dev-org --result-format human --code-coverage -v
## Reference: Classes Deployed
**Apex Classes:**
- `DocusignCompositeEnvelopeBuilder` — Main invocable class (Flows)
- `DocusignCompositeEnvelopeBuilder` — Main invocable class (Flows); includes multi-copy template expansion logic
- `DocusignEnvelopeRequest` — Invocable input DTO; includes `authReleaseFormCopies` field (v1.1)
- `DocusignEnvelopeRequestHandler` — Request validation & envelope building (reusable)
- `DocusignAPIService` — Docusign REST API wrapper
- `DocusignCredentials` — Custom settings singleton
@ -408,6 +443,9 @@ sf apex run test --target-org dev-org --result-format human --code-coverage -v
- `DocusignAPIServiceTest` — Tests for API service
- `DocusignCredentialsTest` — Tests for credentials
**Flows:**
- `Docusign_Envelope_Templates_V3` — Main template selection flow; includes multi-copy dialog for Authorization to Release Information (v1.1)
**Custom Settings:**
- `Docusign_Configuration__c` — Stores Account ID and Base URL
@ -428,3 +466,12 @@ For more details, see:
- `docs/deployment-guide.md` — Detailed deployment instructions
- `docs/api-reference.md` — API reference
- `docs/design.md` — Architecture & design decisions
---
## Change Log
| Version | Date | Author | Summary |
|---------|------|--------|---------|
| 1.0 | 2026-02-23 | Paul Huliganga | Initial release |
| 1.1 | 2026-03-11 | Paul Huliganga | Added multi-copy Authorization to Release Information feature; added "Updating the Multi-Copy Template Name" section; updated Screen Flow setup instructions and class reference |

View File

@ -1,8 +1,8 @@
# API Reference
**Project**: Salesforce Composite Envelope Builder
**Version**: 1.0
**Date**: February 23, 2026
**Version**: 1.1
**Date**: February 23, 2026 (updated March 11, 2026)
---

View File

@ -1,8 +1,8 @@
# Design Document
**Project**: Salesforce Composite Envelope Builder
**Version**: 1.0
**Date**: February 23, 2026
**Version**: 1.1
**Date**: February 23, 2026 (updated March 11, 2026)
**Author**: Paul Huliganga
---
@ -55,6 +55,7 @@
│ │ │ DocusignCompositeEnvelopeBuilder │ │ │
│ │ │ - @InvocableMethod entry point │ │ │
│ │ │ - Input validation │ │ │
│ │ │ - Multi-copy template expansion │ │ │
│ │ │ - Composite JSON construction │ │ │
│ │ │ - Envelope ID return │ │ │
│ │ └──────────────────┬──────────────────────┘ │ │
@ -98,6 +99,7 @@
**Responsibilities**:
- Receive template IDs from Screen Flow
- Validate inputs
- Expand multi-copy templates (e.g. Authorization to Release Information)
- Construct composite template JSON
- Delegate API call to service class
- Return envelope ID to Flow
@ -141,6 +143,9 @@ public class Request {
@InvocableVariable(required=false label='Email Subject')
public String emailSubject;
@InvocableVariable(required=false label='Authorization to Release Form Copies')
public Integer authReleaseFormCopies; // 13; only used when that template is selected
@InvocableVariable(required=false label='Custom Fields')
public Map<String, String> customFields; // For merge fields
}
@ -234,6 +239,95 @@ public DateTime tokenExpiry { get; private set; }
---
## 2.4 Multi-Copy Template Feature (v1.1)
### Overview
Certain templates may need to be included multiple times in a single envelope (e.g. the **Authorization to Release Information** form, available in both English and Spanish). Rather than requiring users to build separate envelopes, the flow detects this template and prompts for a copy count before sending.
### Configuration
The template is identified by a **single constant** in `DocusignCompositeEnvelopeBuilder.cls`:
```apex
// ============================================================
// MULTI-COPY TEMPLATE: Update this if the template name changes.
// Both English and Spanish versions share this base name.
// ============================================================
@TestVisible
private static final String MULTI_COPY_TEMPLATE_NAME = 'Authorization to Release Information';
```
To rename the template, update this one constant. The Apex code uses a `LIKE '%<name>%'` SOQL query, so the match is case-insensitive and partial — it covers both language variants automatically.
The Flow also has a single `Contains` check in the `Does_Row_Contain_Auth_Release` decision node, which must be updated to match.
### Flow Changes
The following new elements were added to `Docusign_Envelope_Templates_V3`:
| Element | Type | Purpose |
|---------|------|---------|
| `Scan_For_Auth_Release_Template` | Loop | Iterates all selected rows to look for the target template |
| `Does_Row_Contain_Auth_Release` | Decision | Checks if the current row's `Name` contains `"Authorization to Release Information"` |
| `Flag_Auth_Release_Selected` | Assignment | Sets `authReleaseTemplateSelected = true` when match is found |
| `Is_Auth_Release_Selected` | Decision | After scan loop: routes to copies screen if flag is true, otherwise skips |
| `Authorization_Copies_Screen` | Screen | Shows instruction text + radio buttons (1 copy / 2 copies / 3 copies) |
| `authReleaseFormCopies` | Variable (Number, default 1) | Stores the user's copy-count selection |
| `authReleaseTemplateSelected` | Variable (Boolean, default false) | Flag set during the scan loop |
| `AuthCopies_1/2/3` | Choices | Radio button options with numeric values 1 / 2 / 3 |
The `authReleaseFormCopies` variable is passed to the Apex Invocable Action as a new input parameter.
#### Updated Flow Path (after row selection)
```
Check_Row_Selection → Scan_For_Auth_Release_Template (loop)
│ per row → Does_Row_Contain_Auth_Release
│ Yes → Flag_Auth_Release_Selected → (continue loop)
│ No → (continue loop)
└ loop ends → Is_Auth_Release_Selected
Yes → Authorization_Copies_Screen → Build_Template_ID_Collection
No → Build_Template_ID_Collection (unchanged)
```
### Apex Changes
**`DocusignEnvelopeRequest.cls`** — new `@InvocableVariable`:
```apex
@InvocableVariable(
label='Authorization to Release Form Copies'
description='Number of times to include the Authorization to Release Information template (1-3).'
required=false
)
global Integer authReleaseFormCopies;
```
**`DocusignCompositeEnvelopeBuilder.cls`** — multi-copy expansion logic runs before the document list is built:
```apex
// Expand multi-copy templates
List<String> expandedTemplateIds = new List<String>(req.templateIds);
Integer copies = (req.authReleaseFormCopies != null && req.authReleaseFormCopies > 1)
? Math.min(req.authReleaseFormCopies, 3) : 1;
if (copies > 1) {
List<String> multiCopyIds = [
SELECT dfsle__DocuSignId__c FROM dfsle__EnvelopeConfiguration__c
WHERE dfsle__DocuSignId__c IN :req.templateIds
AND Name LIKE :('%' + MULTI_COPY_TEMPLATE_NAME + '%')
].dfsle__DocuSignId__c;
for (String id : multiCopyIds) {
for (Integer i = 1; i < copies; i++) {
expandedTemplateIds.add(id);
}
}
}
```
Duplicate template IDs are intentionally **not deduplicated** when multi-copy is in effect. The label builder appends `" (Copy 2)"` / `" (Copy 3)"` suffixes to keep document labels distinct within the envelope.
---
## 3. Data Flow
### 3.1 Sequence Diagram: Send Composite Envelope
@ -645,3 +739,12 @@ Accept: application/json
**Document Status**: Draft
**Next Steps**: Review with stakeholders, begin Apex development
**Estimated Effort**: 3-5 days development + 2 days testing
---
## Change Log
| Version | Date | Author | Summary |
|---------|------|--------|---------|
| 1.0 | 2026-02-23 | Paul Huliganga | Initial release |
| 1.1 | 2026-03-11 | Paul Huliganga | Added section 2.4 — multi-copy Authorization to Release Information feature; updated component diagram, Request inner class, and sequence diagram |

View File

@ -1,8 +1,8 @@
# Requirements Document
**Project**: Salesforce Composite Envelope Builder
**Version**: 1.0
**Date**: February 23, 2026
**Version**: 1.1
**Date**: February 23, 2026 (updated March 11, 2026)
**Author**: Paul Huliganga
---
@ -44,6 +44,17 @@ Replace combination templates with **28 single-form templates** (14 forms × 2 l
- Minimum 1 form, maximum 14 forms per envelope
- User can select all, none, or any combination
#### FR-006: Multiple Copies of Authorization to Release Information
**Priority**: Medium
**Description**: When the "Authorization to Release Information" template (English or Spanish) is selected, users may include 1, 2, or 3 copies of that form in the same envelope
**Acceptance Criteria**:
- After template selection, if "Authorization to Release Information" is among the selected templates, an additional dialog screen is displayed before sending
- The dialog presents a radio-button selection: **1 copy** (default), **2 copies**, **3 copies**
- If the user selects 2 or 3 copies, the template is added to the envelope that many times, each appearing as a distinct document
- Additional copies are labelled with a `(Copy N)` suffix in the envelope document list so they are distinguishable
- If "Authorization to Release Information" is not selected, the dialog is skipped entirely and default behaviour is unchanged
- The template name used for matching is stored in a single constant (`MULTI_COPY_TEMPLATE_NAME`) in the Apex class and a single string value in the Flow decision, making it straightforward to update if the template is renamed
#### FR-003: Single Envelope Generation
**Priority**: High
**Description**: All selected forms must be combined into ONE envelope
@ -202,6 +213,20 @@ Replace combination templates with **28 single-form templates** (14 forms × 2 l
- And envelope ID is returned to Salesforce
- And I see a success confirmation
### US-005: Request Multiple Copies of Authorization to Release Information
**As a** Salesforce user
**I want to** include more than one copy of the Authorization to Release Information form in a single envelope
**So that** I can obtain multiple authorisations in one signing ceremony
**Acceptance Criteria**:
- Given I have selected the "Authorization to Release Information" template (English or Spanish) along with any other forms
- When I click "Send" on the template selection screen
- Then a new dialog appears asking "How many copies of this form should be included in the envelope?"
- And the dialog offers radio-button options: 1 copy (pre-selected), 2 copies, 3 copies
- When I select 2 copies and click "Next"
- Then the resulting envelope contains 2 copies of the Authorization form plus all other selected forms
- And I see the standard success confirmation after sending
### US-004: View Completed Documents
**As a** Salesforce user
**I want to** see completed documents attached to the Salesforce record
@ -296,6 +321,16 @@ The following are explicitly out of scope for the initial release:
4. **Bulk operations**: Send envelopes to multiple records
5. **Template management UI**: Admin UI for template configuration
6. **Analytics**: Track which form combinations are most common
7. **Configurable multi-copy forms**: Extend the multi-copy pattern to other templates without code changes (admin-configurable list)
---
## 11. Change Log
| Version | Date | Author | Summary |
|---------|------|--------|---------|
| 1.0 | 2026-02-23 | Paul Huliganga | Initial release |
| 1.1 | 2026-03-11 | Paul Huliganga | Added FR-006 (multi-copy Authorization to Release Information), US-005, updated constraints |
---