# 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](docs/deployment-guide.md) for setup instructions. ## Documentation - [Requirements](docs/requirements.md) - Functional and technical requirements - [Design](docs/design.md) - Architecture, sequence diagrams, data flow - [API Reference](docs/api-reference.md) - Docusign REST API integration details - [Deployment Guide](docs/deployment-guide.md) - Installation and configuration ## 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