Compare commits
No commits in common. "86e7d2fb623a748ee2a6632cff6008bfecb13415" and "30fc345bb040682968835788c5ee7b6a53d3ecad" have entirely different histories.
86e7d2fb62
...
30fc345bb0
|
|
@ -218,37 +218,6 @@ 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.
|
||||
|
|
@ -357,15 +326,12 @@ 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 (1–3) 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
|
||||
|
|
@ -431,8 +397,7 @@ sf apex run test --target-org dev-org --result-format human --code-coverage -v
|
|||
## Reference: Classes Deployed
|
||||
|
||||
**Apex Classes:**
|
||||
- `DocusignCompositeEnvelopeBuilder` — Main invocable class (Flows); includes multi-copy template expansion logic
|
||||
- `DocusignEnvelopeRequest` — Invocable input DTO; includes `authReleaseFormCopies` field (v1.1)
|
||||
- `DocusignCompositeEnvelopeBuilder` — Main invocable class (Flows)
|
||||
- `DocusignEnvelopeRequestHandler` — Request validation & envelope building (reusable)
|
||||
- `DocusignAPIService` — Docusign REST API wrapper
|
||||
- `DocusignCredentials` — Custom settings singleton
|
||||
|
|
@ -443,9 +408,6 @@ 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
|
||||
|
||||
|
|
@ -466,12 +428,3 @@ 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 |
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# API Reference
|
||||
|
||||
**Project**: Salesforce Composite Envelope Builder
|
||||
**Version**: 1.1
|
||||
**Date**: February 23, 2026 (updated March 11, 2026)
|
||||
**Version**: 1.0
|
||||
**Date**: February 23, 2026
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# Design Document
|
||||
|
||||
**Project**: Salesforce Composite Envelope Builder
|
||||
**Version**: 1.1
|
||||
**Date**: February 23, 2026 (updated March 11, 2026)
|
||||
**Version**: 1.0
|
||||
**Date**: February 23, 2026
|
||||
**Author**: Paul Huliganga
|
||||
|
||||
---
|
||||
|
|
@ -52,10 +52,9 @@
|
|||
│ │ Business Logic Layer (Apex) │ │
|
||||
│ │ │ │
|
||||
│ │ ┌─────────────────────────────────────────┐ │ │
|
||||
│ │ │ DocusignCompositeEnvelopeBuilder │ │ │
|
||||
│ │ │ DocusignCompositeEnvelopeBuilder │ │ │
|
||||
│ │ │ - @InvocableMethod entry point │ │ │
|
||||
│ │ │ - Input validation │ │ │
|
||||
│ │ │ - Multi-copy template expansion │ │ │
|
||||
│ │ │ - Composite JSON construction │ │ │
|
||||
│ │ │ - Envelope ID return │ │ │
|
||||
│ │ └──────────────────┬──────────────────────┘ │ │
|
||||
|
|
@ -99,7 +98,6 @@
|
|||
**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
|
||||
|
|
@ -143,9 +141,6 @@ public class Request {
|
|||
@InvocableVariable(required=false label='Email Subject')
|
||||
public String emailSubject;
|
||||
|
||||
@InvocableVariable(required=false label='Authorization to Release Form Copies')
|
||||
public Integer authReleaseFormCopies; // 1–3; only used when that template is selected
|
||||
|
||||
@InvocableVariable(required=false label='Custom Fields')
|
||||
public Map<String, String> customFields; // For merge fields
|
||||
}
|
||||
|
|
@ -239,95 +234,6 @@ 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
|
||||
|
|
@ -739,12 +645,3 @@ 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 |
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# Requirements Document
|
||||
|
||||
**Project**: Salesforce Composite Envelope Builder
|
||||
**Version**: 1.1
|
||||
**Date**: February 23, 2026 (updated March 11, 2026)
|
||||
**Version**: 1.0
|
||||
**Date**: February 23, 2026
|
||||
**Author**: Paul Huliganga
|
||||
|
||||
---
|
||||
|
|
@ -44,17 +44,6 @@ 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
|
||||
|
|
@ -213,20 +202,6 @@ 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
|
||||
|
|
@ -321,16 +296,6 @@ 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 |
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
|
|
@ -19,15 +19,6 @@ global with sharing class DocusignCompositeEnvelopeBuilder {
|
|||
// Role names must match EXACTLY what's configured in the Docusign templates
|
||||
private static final String ROLE_SERVICE_COORDINATOR = 'Service Coordinator';
|
||||
private static final String ROLE_DOCUSIGN_RECIPIENT = 'Docusign Recipient #1';
|
||||
|
||||
// ============================================================
|
||||
// MULTI-COPY TEMPLATE: Update this if the template name changes.
|
||||
// This is matched against the dfsle__EnvelopeConfiguration__c Name
|
||||
// field using a case-insensitive contains check.
|
||||
// Both English and Spanish versions share this base name.
|
||||
// ============================================================
|
||||
@TestVisible
|
||||
private static final String MULTI_COPY_TEMPLATE_NAME = 'Authorization to Release Information';
|
||||
|
||||
@InvocableMethod(
|
||||
label='Send Composite Docusign Envelope'
|
||||
|
|
@ -53,38 +44,8 @@ global with sharing class DocusignCompositeEnvelopeBuilder {
|
|||
new dfsle.Entity(req.recordId)
|
||||
);
|
||||
|
||||
// Expand multi-copy templates before deduplication.
|
||||
// If the user selected the Authorization to Release Information template and
|
||||
// requested more than 1 copy, insert additional copies of its template ID into
|
||||
// the list now so the deduplication step handles all IDs uniformly.
|
||||
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) {
|
||||
// Find which template ID(s) correspond to the multi-copy template
|
||||
List<String> multiCopyIds = new List<String>();
|
||||
for (dfsle__EnvelopeConfiguration__c config : [
|
||||
SELECT dfsle__DocuSignId__c
|
||||
FROM dfsle__EnvelopeConfiguration__c
|
||||
WHERE dfsle__DocuSignId__c IN :req.templateIds
|
||||
AND Name LIKE :('%' + MULTI_COPY_TEMPLATE_NAME + '%')
|
||||
]) {
|
||||
multiCopyIds.add(config.dfsle__DocuSignId__c);
|
||||
}
|
||||
// Add (copies - 1) additional entries for each matched template ID
|
||||
for (String multiId : multiCopyIds) {
|
||||
for (Integer i = 1; i < copies; i++) {
|
||||
expandedTemplateIds.add(multiId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build document list from templates.
|
||||
// NOTE: We intentionally do NOT deduplicate here so that multiple copies of
|
||||
// the same template ID produce distinct documents in the envelope.
|
||||
// We sort by label after resolving names instead.
|
||||
List<String> sortedTemplateIds = new List<String>(expandedTemplateIds);
|
||||
// Build document list from templates (deduplicated and sorted)
|
||||
List<String> sortedTemplateIds = new List<String>(new Set<String>(req.templateIds));
|
||||
sortedTemplateIds.sort();
|
||||
|
||||
// Query template names for document labels (shows in Docusign Status)
|
||||
|
|
@ -104,10 +65,7 @@ global with sharing class DocusignCompositeEnvelopeBuilder {
|
|||
|
||||
List<dfsle.Document> documents = new List<dfsle.Document>();
|
||||
List<String> docNames = new List<String>();
|
||||
// Use a list of label+id pairs to correctly handle duplicate template IDs
|
||||
// (e.g. multiple copies of Authorization to Release Information)
|
||||
List<String[]> labelIdPairs = new List<String[]>();
|
||||
Map<String, Integer> labelCounters = new Map<String, Integer>();
|
||||
Map<String, String> labelToId = new Map<String, String>();
|
||||
for (String templateId : sortedTemplateIds) {
|
||||
String label;
|
||||
if (templateShortNames.containsKey(templateId)) {
|
||||
|
|
@ -117,24 +75,10 @@ global with sharing class DocusignCompositeEnvelopeBuilder {
|
|||
} else {
|
||||
label = templateId;
|
||||
}
|
||||
// If the same label appears more than once, append " (Copy N)" to distinguish
|
||||
if (labelCounters.containsKey(label)) {
|
||||
Integer count = labelCounters.get(label) + 1;
|
||||
labelCounters.put(label, count);
|
||||
label = label + ' (Copy ' + count + ')';
|
||||
} else {
|
||||
labelCounters.put(label, 1);
|
||||
}
|
||||
labelIdPairs.add(new String[]{ label, templateId });
|
||||
labelToId.put(label, templateId);
|
||||
docNames.add(label);
|
||||
}
|
||||
// Sort by label for consistent ordering
|
||||
docNames.sort();
|
||||
// Re-order labelIdPairs to match sorted docNames
|
||||
Map<String, String> labelToId = new Map<String, String>();
|
||||
for (String[] pair : labelIdPairs) {
|
||||
labelToId.put(pair[0], pair[1]);
|
||||
}
|
||||
List<String> sortedIds = new List<String>();
|
||||
for (String label : docNames) {
|
||||
sortedIds.add(labelToId.get(label));
|
||||
|
|
@ -151,30 +95,9 @@ global with sharing class DocusignCompositeEnvelopeBuilder {
|
|||
}
|
||||
myEnvelope = myEnvelope.withDocuments(documents);
|
||||
|
||||
// Build a deduplicated display list for the email subject and body.
|
||||
// Where a template appears more than once (multi-copy), show the base label
|
||||
// once with a " [x N]" count suffix, e.g. "Authorization to Release Information [x 3]".
|
||||
// This keeps the subject and body clean while the envelope still contains all copies.
|
||||
Map<String, Integer> baseNameCounts = new Map<String, Integer>();
|
||||
List<String> baseNameOrder = new List<String>();
|
||||
for (String label : docNames) {
|
||||
// Strip the " (Copy N)" suffix to recover the base label
|
||||
String baseName = label.replaceAll(' \\(Copy \\d+\\)$', '');
|
||||
if (!baseNameCounts.containsKey(baseName)) {
|
||||
baseNameCounts.put(baseName, 0);
|
||||
baseNameOrder.add(baseName);
|
||||
}
|
||||
baseNameCounts.put(baseName, baseNameCounts.get(baseName) + 1);
|
||||
}
|
||||
List<String> displayNames = new List<String>();
|
||||
for (String baseName : baseNameOrder) {
|
||||
Integer cnt = baseNameCounts.get(baseName);
|
||||
displayNames.add(cnt > 1 ? baseName + ' (' + cnt + ')' : baseName);
|
||||
}
|
||||
|
||||
// Set combined template names as the envelope document name
|
||||
// (shows in Docusign Status "Document Name" column)
|
||||
String combinedName = String.join(displayNames, ', ');
|
||||
String combinedName = String.join(docNames, ', ');
|
||||
if (combinedName.length() > 255) {
|
||||
combinedName = combinedName.left(252) + '...';
|
||||
}
|
||||
|
|
@ -191,27 +114,22 @@ global with sharing class DocusignCompositeEnvelopeBuilder {
|
|||
List<dfsle.Recipient> recipients = resolveRecipients(req.recordId);
|
||||
myEnvelope = myEnvelope.withRecipients(recipients);
|
||||
|
||||
// Set envelope subject to combined display names (deduplicated, with copy counts).
|
||||
// Query for EmailMessage__c — use a deduplicated set of template IDs so each
|
||||
// template's body text is included only once even when multi-copy is in effect.
|
||||
Set<String> uniqueTemplateIds = new Set<String>(sortedIds);
|
||||
// Set envelope subject to combined template names and body to concatenated template email messages
|
||||
// Query for EmailMessage__c
|
||||
Map<String, String> templateBodies = new Map<String, String>();
|
||||
for (dfsle__EnvelopeConfiguration__c config : [
|
||||
SELECT dfsle__DocuSignId__c, dfsle__EmailMessage__c
|
||||
FROM dfsle__EnvelopeConfiguration__c
|
||||
WHERE dfsle__DocuSignId__c IN :uniqueTemplateIds
|
||||
WHERE dfsle__DocuSignId__c IN :sortedTemplateIds
|
||||
]) {
|
||||
if (String.isNotBlank(config.dfsle__EmailMessage__c)) {
|
||||
templateBodies.put(config.dfsle__DocuSignId__c, config.dfsle__EmailMessage__c);
|
||||
}
|
||||
}
|
||||
// Build body using one entry per unique template ID (preserving sorted order)
|
||||
Set<String> bodyIdsAdded = new Set<String>();
|
||||
List<String> bodyParts = new List<String>();
|
||||
for (String templateId : sortedIds) {
|
||||
if (templateBodies.containsKey(templateId) && !bodyIdsAdded.contains(templateId)) {
|
||||
if (templateBodies.containsKey(templateId)) {
|
||||
bodyParts.add(templateBodies.get(templateId));
|
||||
bodyIdsAdded.add(templateId);
|
||||
}
|
||||
}
|
||||
String envelopeSubject = combinedName;
|
||||
|
|
@ -230,7 +148,7 @@ global with sharing class DocusignCompositeEnvelopeBuilder {
|
|||
result.success = true;
|
||||
result.errorMessage = null;
|
||||
|
||||
logResult(sortedTemplateIds.size(), result.envelopeId, 'Success (' + String.join(displayNames, ', ') + ')', null);
|
||||
logResult(sortedTemplateIds.size(), result.envelopeId, 'Success (' + String.join(docNames, ', ') + ')', null);
|
||||
|
||||
} catch (Exception e) {
|
||||
result.success = false;
|
||||
|
|
|
|||
|
|
@ -32,11 +32,4 @@ global class DocusignEnvelopeRequest {
|
|||
required=false
|
||||
)
|
||||
global String emailSubject;
|
||||
|
||||
@InvocableVariable(
|
||||
label='Authorization to Release Form Copies'
|
||||
description='Number of times to include the Authorization to Release Information template (1-3). Only used when that template is selected.'
|
||||
required=false
|
||||
)
|
||||
global Integer authReleaseFormCopies;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,12 +29,6 @@
|
|||
<elementReference>Get_Records.Docusign_Envelope_Language__c</elementReference>
|
||||
</value>
|
||||
</inputParameters>
|
||||
<inputParameters>
|
||||
<name>authReleaseFormCopies</name>
|
||||
<value>
|
||||
<elementReference>authReleaseFormCopies</elementReference>
|
||||
</value>
|
||||
</inputParameters>
|
||||
<nameSegment>DocusignCompositeEnvelopeBuilder</nameSegment>
|
||||
<offset>0</offset>
|
||||
<outputParameters>
|
||||
|
|
@ -56,7 +50,7 @@
|
|||
<name>Add_Template_ID</name>
|
||||
<label>Add Template ID</label>
|
||||
<locationX>270</locationX>
|
||||
<locationY>1106</locationY>
|
||||
<locationY>890</locationY>
|
||||
<assignmentItems>
|
||||
<assignToReference>compositeTemplateIds</assignToReference>
|
||||
<operator>Add</operator>
|
||||
|
|
@ -68,38 +62,6 @@
|
|||
<targetReference>Build_Template_ID_Collection</targetReference>
|
||||
</connector>
|
||||
</assignments>
|
||||
<assignments>
|
||||
<name>Flag_Auth_Release_Selected</name>
|
||||
<label>Flag Authorization to Release Template Selected</label>
|
||||
<locationX>270</locationX>
|
||||
<locationY>1000</locationY>
|
||||
<assignmentItems>
|
||||
<assignToReference>authReleaseTemplateSelected</assignToReference>
|
||||
<operator>Assign</operator>
|
||||
<value>
|
||||
<booleanValue>true</booleanValue>
|
||||
</value>
|
||||
</assignmentItems>
|
||||
<connector>
|
||||
<targetReference>Scan_For_Auth_Release_Template</targetReference>
|
||||
</connector>
|
||||
</assignments>
|
||||
<assignments>
|
||||
<name>Store_Auth_Release_Copies</name>
|
||||
<label>Store Authorization to Release Copies Selection</label>
|
||||
<locationX>182</locationX>
|
||||
<locationY>1160</locationY>
|
||||
<assignmentItems>
|
||||
<assignToReference>authReleaseFormCopies</assignToReference>
|
||||
<operator>Assign</operator>
|
||||
<value>
|
||||
<elementReference>authReleaseFormCopies_Radio</elementReference>
|
||||
</value>
|
||||
</assignmentItems>
|
||||
<connector>
|
||||
<targetReference>Build_Template_ID_Collection</targetReference>
|
||||
</connector>
|
||||
</assignments>
|
||||
<decisions>
|
||||
<name>Check_Envelope_Result</name>
|
||||
<label>Check Envelope Result</label>
|
||||
|
|
@ -145,36 +107,11 @@
|
|||
</rightValue>
|
||||
</conditions>
|
||||
<connector>
|
||||
<targetReference>Scan_For_Auth_Release_Template</targetReference>
|
||||
<targetReference>Build_Template_ID_Collection</targetReference>
|
||||
</connector>
|
||||
<label>Is Row Selected?</label>
|
||||
</rules>
|
||||
</decisions>
|
||||
<decisions>
|
||||
<name>Is_Auth_Release_Selected</name>
|
||||
<label>Is Authorization to Release Info Selected?</label>
|
||||
<locationX>380</locationX>
|
||||
<locationY>890</locationY>
|
||||
<defaultConnector>
|
||||
<targetReference>Build_Template_ID_Collection</targetReference>
|
||||
</defaultConnector>
|
||||
<defaultConnectorLabel>No - Proceed</defaultConnectorLabel>
|
||||
<rules>
|
||||
<name>Auth_Release_Template_Found</name>
|
||||
<conditionLogic>and</conditionLogic>
|
||||
<conditions>
|
||||
<leftValueReference>authReleaseTemplateSelected</leftValueReference>
|
||||
<operator>EqualTo</operator>
|
||||
<rightValue>
|
||||
<booleanValue>true</booleanValue>
|
||||
</rightValue>
|
||||
</conditions>
|
||||
<connector>
|
||||
<targetReference>Authorization_Copies_Screen</targetReference>
|
||||
</connector>
|
||||
<label>Yes - Ask for copies</label>
|
||||
</rules>
|
||||
</decisions>
|
||||
<decisions>
|
||||
<name>Is_Language_Selected</name>
|
||||
<label>Is Language Selected?</label>
|
||||
|
|
@ -200,31 +137,6 @@
|
|||
<label>Language Selected?</label>
|
||||
</rules>
|
||||
</decisions>
|
||||
<decisions>
|
||||
<name>Does_Row_Contain_Auth_Release</name>
|
||||
<label>Does This Row Contain Authorization to Release Info?</label>
|
||||
<locationX>270</locationX>
|
||||
<locationY>890</locationY>
|
||||
<defaultConnector>
|
||||
<targetReference>Scan_For_Auth_Release_Template</targetReference>
|
||||
</defaultConnector>
|
||||
<defaultConnectorLabel>No</defaultConnectorLabel>
|
||||
<rules>
|
||||
<name>Row_Is_Auth_Release_Template</name>
|
||||
<conditionLogic>and</conditionLogic>
|
||||
<conditions>
|
||||
<leftValueReference>Scan_For_Auth_Release_Template.Name</leftValueReference>
|
||||
<operator>Contains</operator>
|
||||
<rightValue>
|
||||
<stringValue>Authorization to Release Information</stringValue>
|
||||
</rightValue>
|
||||
</conditions>
|
||||
<connector>
|
||||
<targetReference>Flag_Auth_Release_Selected</targetReference>
|
||||
</connector>
|
||||
<label>Yes</label>
|
||||
</rules>
|
||||
</decisions>
|
||||
<environments>Default</environments>
|
||||
<interviewLabel>Docusign Envelope Templates V3 {!$Flow.CurrentDateTime}</interviewLabel>
|
||||
<label>Docusign Envelope Templates V3</label>
|
||||
|
|
@ -232,7 +144,7 @@
|
|||
<name>Build_Template_ID_Collection</name>
|
||||
<label>Build Template ID Collection</label>
|
||||
<locationX>182</locationX>
|
||||
<locationY>1214</locationY>
|
||||
<locationY>782</locationY>
|
||||
<collectionReference>data.selectedRows</collectionReference>
|
||||
<iterationOrder>Asc</iterationOrder>
|
||||
<nextValueConnector>
|
||||
|
|
@ -242,20 +154,6 @@
|
|||
<targetReference>Send_Composite_Envelope</targetReference>
|
||||
</noMoreValuesConnector>
|
||||
</loops>
|
||||
<loops>
|
||||
<name>Scan_For_Auth_Release_Template</name>
|
||||
<label>Scan For Authorization to Release Template</label>
|
||||
<locationX>380</locationX>
|
||||
<locationY>782</locationY>
|
||||
<collectionReference>data.selectedRows</collectionReference>
|
||||
<iterationOrder>Asc</iterationOrder>
|
||||
<nextValueConnector>
|
||||
<targetReference>Does_Row_Contain_Auth_Release</targetReference>
|
||||
</nextValueConnector>
|
||||
<noMoreValuesConnector>
|
||||
<targetReference>Is_Auth_Release_Selected</targetReference>
|
||||
</noMoreValuesConnector>
|
||||
</loops>
|
||||
<processMetadataValues>
|
||||
<name>BuilderType</name>
|
||||
<value>
|
||||
|
|
@ -397,55 +295,6 @@
|
|||
<showFooter>true</showFooter>
|
||||
<showHeader>true</showHeader>
|
||||
</screens>
|
||||
<screens>
|
||||
<name>Authorization_Copies_Screen</name>
|
||||
<label>Authorization to Release Info - Number of Copies</label>
|
||||
<locationX>182</locationX>
|
||||
<locationY>1106</locationY>
|
||||
<allowBack>true</allowBack>
|
||||
<allowFinish>true</allowFinish>
|
||||
<allowPause>false</allowPause>
|
||||
<backButtonLabel>Back</backButtonLabel>
|
||||
<connector>
|
||||
<targetReference>Store_Auth_Release_Copies</targetReference>
|
||||
</connector>
|
||||
<fields>
|
||||
<name>AuthCopiesHeader</name>
|
||||
<fieldText><p>The <strong>Authorization to Release Information</strong> form was selected.</p><p>How many copies of this form should be included in the envelope?</p></fieldText>
|
||||
<fieldType>DisplayText</fieldType>
|
||||
<styleProperties>
|
||||
<verticalAlignment>
|
||||
<stringValue>top</stringValue>
|
||||
</verticalAlignment>
|
||||
<width>
|
||||
<stringValue>12</stringValue>
|
||||
</width>
|
||||
</styleProperties>
|
||||
</fields>
|
||||
<fields>
|
||||
<name>authReleaseFormCopies_Radio</name>
|
||||
<choiceReferences>AuthCopies_1</choiceReferences>
|
||||
<choiceReferences>AuthCopies_2</choiceReferences>
|
||||
<choiceReferences>AuthCopies_3</choiceReferences>
|
||||
<dataType>Number</dataType>
|
||||
<defaultSelectedChoiceReference>AuthCopies_1</defaultSelectedChoiceReference>
|
||||
<fieldText>Number of Copies</fieldText>
|
||||
<fieldType>RadioButtons</fieldType>
|
||||
<isRequired>true</isRequired>
|
||||
<scale>0</scale>
|
||||
<styleProperties>
|
||||
<verticalAlignment>
|
||||
<stringValue>top</stringValue>
|
||||
</verticalAlignment>
|
||||
<width>
|
||||
<stringValue>12</stringValue>
|
||||
</width>
|
||||
</styleProperties>
|
||||
</fields>
|
||||
<nextOrFinishButtonLabel>Next</nextOrFinishButtonLabel>
|
||||
<showFooter>true</showFooter>
|
||||
<showHeader>true</showHeader>
|
||||
</screens>
|
||||
<screens>
|
||||
<name>Error_Screen</name>
|
||||
<label>Error Screen</label>
|
||||
|
|
@ -615,49 +464,4 @@
|
|||
<isInput>true</isInput>
|
||||
<isOutput>false</isOutput>
|
||||
</variables>
|
||||
<variables>
|
||||
<name>authReleaseFormCopies</name>
|
||||
<dataType>Number</dataType>
|
||||
<isCollection>false</isCollection>
|
||||
<isInput>false</isInput>
|
||||
<isOutput>false</isOutput>
|
||||
<scale>0</scale>
|
||||
<value>
|
||||
<numberValue>1.0</numberValue>
|
||||
</value>
|
||||
</variables>
|
||||
<variables>
|
||||
<name>authReleaseTemplateSelected</name>
|
||||
<dataType>Boolean</dataType>
|
||||
<isCollection>false</isCollection>
|
||||
<isInput>false</isInput>
|
||||
<isOutput>false</isOutput>
|
||||
<value>
|
||||
<booleanValue>false</booleanValue>
|
||||
</value>
|
||||
</variables>
|
||||
<choices>
|
||||
<name>AuthCopies_1</name>
|
||||
<choiceText>1 copy</choiceText>
|
||||
<dataType>Number</dataType>
|
||||
<value>
|
||||
<numberValue>1.0</numberValue>
|
||||
</value>
|
||||
</choices>
|
||||
<choices>
|
||||
<name>AuthCopies_2</name>
|
||||
<choiceText>2 copies</choiceText>
|
||||
<dataType>Number</dataType>
|
||||
<value>
|
||||
<numberValue>2.0</numberValue>
|
||||
</value>
|
||||
</choices>
|
||||
<choices>
|
||||
<name>AuthCopies_3</name>
|
||||
<choiceText>3 copies</choiceText>
|
||||
<dataType>Number</dataType>
|
||||
<value>
|
||||
<numberValue>3.0</numberValue>
|
||||
</value>
|
||||
</choices>
|
||||
</Flow>
|
||||
|
|
|
|||
Loading…
Reference in New Issue