salesforce-composite-envelo.../composite-envelope-builder
Paul Huliganga 85677a3ff1 style: visually separate template bodies with '\n\n---\n\n' divider in email body 2026-02-25 23:59:54 -05: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: add template ID update instructions for sandbox refresh 2026-02-25 13:19:44 -05:00
force-app/main/default style: visually separate template bodies with '\n\n---\n\n' divider in email body 2026-02-25 23:59:54 -05: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