salesforce-composite-envelo.../composite-envelope-builder
Paul Huliganga 40798dfe63 feat(sms): draft envelope + Docusign Sender View for recipients without email
When the primary recipient (Docusign Recipient #1) has no email address, the
envelope is created in draft status and the sender completes delivery manually
in the Docusign Sender View web console where they can configure SMS delivery.

Apex changes:
- DocusignCompositeEnvelopeBuilder: new DRAFT_PLACEHOLDER_EMAIL constant; when
  requiresDraftMode=true calls sendEnvelope(envelope, false) to create a draft,
  then builds and returns a Sender View URL via buildSenderViewUrl(); buildRecipient
  accepts allowPlaceholderEmail flag and substitutes placeholder when email is blank
- DocusignEnvelopeRequest: new requiresDraftMode Boolean InvocableVariable
- DocusignEnvelopeResult: new senderViewUrl String InvocableVariable

Flow (V3) changes:
- Get_Records now fetches Docusign_Recipient_1__c
- New Get_Recipient_Contact lookup queries Contact.Email and Name
- New Is_Recipient_Email_Blank decision routes to Set_Draft_Mode when blank
- New Set_Draft_Mode assignment sets requiresDraftMode=true
- New No_Email_Warning_Screen explains the draft process and required steps
- requiresDraftMode passed as input; senderViewUrl captured as output
- New Is_Draft_Envelope decision routes to Sender_View_Screen or Success_Screen
- New Sender_View_Screen shows clickable link, placeholder email, and step-by-step
  instructions for configuring SMS delivery in the Docusign web console
2026-03-13 00:08:59 -04:00
..
.husky Initial commit: Salesforce Composite Envelope Builder 2026-02-25 09:22:29 -05:00
config Initial commit: Salesforce Composite Envelope Builder 2026-02-25 09:22:29 -05:00
docs docs: update documentation for multi-copy Authorization to Release feature 2026-03-11 16:24:04 -04:00
force-app/main/default feat(sms): draft envelope + Docusign Sender View for recipients without email 2026-03-13 00:08:59 -04:00
scripts Initial commit: Salesforce Composite Envelope Builder 2026-02-25 09:22:29 -05:00
.forceignore Initial commit: Salesforce Composite Envelope Builder 2026-02-25 09:22:29 -05:00
.gitignore Initial commit: Salesforce Composite Envelope Builder 2026-02-25 09:22:29 -05:00
.prettierignore Initial commit: Salesforce Composite Envelope Builder 2026-02-25 09:22:29 -05:00
.prettierrc Initial commit: Salesforce Composite Envelope Builder 2026-02-25 09:22:29 -05:00
QUICK_START.md Initial commit: Salesforce Composite Envelope Builder 2026-02-25 09:22:29 -05:00
README.md Initial commit: Salesforce Composite Envelope Builder 2026-02-25 09:22:29 -05:00
deploy-to-dev-org.sh Initial commit: Salesforce Composite Envelope Builder 2026-02-25 09:22:29 -05:00
deploy.sh Initial commit: Salesforce Composite Envelope Builder 2026-02-25 09:22:29 -05:00
eslint.config.js Initial commit: Salesforce Composite Envelope Builder 2026-02-25 09:22:29 -05:00
jest.config.js Initial commit: Salesforce Composite Envelope Builder 2026-02-25 09:22:29 -05:00
package.json Initial commit: Salesforce Composite Envelope Builder 2026-02-25 09:22:29 -05:00
sfdx-project.json Initial commit: Salesforce Composite Envelope Builder 2026-02-25 09:22:29 -05:00

README.md

Salesforce Composite Envelope Builder

Project Overview

A Salesforce solution for sending multiple Docusign templates in a single envelope using composite template functionality via the Docusign REST API.

Problem Statement

Current implementation requires 42+ pre-built Docusign templates for various combinations of 14 forms (English + Spanish). This approach is:

  • Difficult to maintain
  • Cannot handle all possible combinations
  • Requires creating new templates for each scenario

Solution

Build custom Apex code to dynamically combine multiple single-form templates into one envelope at runtime, allowing users to select any combination of forms.

Key Features

  • Dynamic Form Selection: Users select forms via Salesforce Screen Flow checkboxes
  • Single Template Per Form: 28 templates total (14 forms × 2 languages)
  • Composite Envelope API: Combines templates into one envelope via Docusign REST API
  • Alphabetical Ordering: Forms presented and combined in alphabetical order by title
  • Automatic Recipient Merge: Recipients/roles automatically merged across templates
  • Salesforce Integration: Documents written back to initiating Salesforce record

Technical Architecture

Components

  1. Salesforce Screen Flow (existing, minor modifications)

    • Language selection
    • Template display and selection (checkboxes)
    • Calls Apex action with selected template IDs
  2. Custom Apex Class (new)

    • DocusignCompositeEnvelopeBuilder - Invocable method for Flow integration
    • Constructs composite envelope JSON
    • Makes Docusign REST API callout
    • Returns envelope ID to Flow
  3. Unit Tests (new)

    • Test class with >75% code coverage
    • Mock callouts for Docusign API
    • Edge case handling

Technologies

  • Salesforce Platform: Apex, Screen Flows, Lightning Web Components (potential future UI)
  • Docusign REST API v2.1: Composite Templates endpoint
  • VS Code + Salesforce Extensions: Development environment

Project Structure

salesforce-composite-envelope-builder/
├── docs/
│   ├── requirements.md           # Detailed requirements
│   ├── design.md                 # Architecture and design decisions
│   ├── api-reference.md          # Docusign API integration details
│   └── deployment-guide.md       # Deployment and configuration
├── force-app/main/default/
│   ├── classes/
│   │   ├── DocusignCompositeEnvelopeBuilder.cls
│   │   ├── DocusignCompositeEnvelopeBuilder.cls-meta.xml
│   │   ├── DocusignCompositeEnvelopeBuilderTest.cls
│   │   ├── DocusignCompositeEnvelopeBuilderTest.cls-meta.xml
│   │   ├── DocusignCredentials.cls
│   │   └── DocusignCredentials.cls-meta.xml
│   └── flows/
│       └── Form_Selection_Flow.flow-meta.xml (example/reference)
├── scripts/
│   └── apex/
│       └── test-composite-envelope.apex  # Manual testing script
└── README.md                      # This file

Getting Started

See docs/deployment-guide.md for setup instructions.

Documentation

Timeline

  • Phase 1: Requirements & Design Documentation
  • Phase 2: Apex Class Development
  • Phase 3: Unit Tests & Code Coverage
  • Phase 4: Flow Integration
  • Phase 5: Testing & Deployment

License

Internal project for customer implementation.


Last Updated: February 23, 2026
Project Lead: Paul Huliganga
Status: In Development