9.4 KiB
Requirements Document
Project: Salesforce Composite Envelope Builder
Version: 1.0
Date: February 23, 2026
Author: Paul Huliganga
1. Executive Summary
1.1 Purpose
Enable Salesforce users to dynamically select and send multiple Docusign form templates in a single envelope, eliminating the need for pre-built combination templates.
1.2 Business Problem
- Current system has 42 pre-built templates for various combinations of 14 forms
- Maintenance burden: every new combination requires a new template
- Cannot handle all possible combinations (14 forms = 16,384 possible combinations)
- User confusion: difficult to find the right pre-built combination template
1.3 Solution Overview
Replace combination templates with 28 single-form templates (14 forms × 2 languages). Build custom Apex code to dynamically combine selected templates into one envelope at runtime using Docusign's Composite Templates API.
2. Business Requirements
2.1 Functional Requirements
FR-001: Multi-Language Support
Priority: High
Description: System must support English and Spanish forms
Acceptance Criteria:
- User selects language before form selection
- Only templates in selected language are displayed
- All forms in envelope are in same language
FR-002: Dynamic Form Selection
Priority: High
Description: Users can select any combination of forms to include in envelope
Acceptance Criteria:
- Forms displayed in alphabetical order by title
- Checkbox interface for selection (existing Screen Flow UI)
- Minimum 1 form, maximum 14 forms per envelope
- User can select all, none, or any combination
FR-003: Single Envelope Generation
Priority: High
Description: All selected forms must be combined into ONE envelope
Acceptance Criteria:
- One envelope ID returned
- One email sent to recipients
- One signing ceremony
- Documents appear in selected order
FR-004: Consistent Recipients
Priority: High
Description: All forms go to the same 2 recipients for review and signature
Acceptance Criteria:
- Recipient 1: Review and sign
- Recipient 2: Review and sign
- Same roles across all templates
- Recipients automatically merged by Docusign
FR-005: Salesforce Document Storage
Priority: High
Description: Completed envelope documents written back to initiating Salesforce record
Acceptance Criteria:
- Documents attached to correct record
- All forms from envelope stored
- Metadata preserved (envelope ID, completion date, signers)
2.2 Non-Functional Requirements
NFR-001: Performance
Priority: Medium
Description: Envelope creation must complete within acceptable timeframe
Acceptance Criteria:
- Apex execution time < 10 seconds
- No Salesforce governor limit violations
- REST API call timeout handled gracefully
NFR-002: Maintainability
Priority: High
Description: Code must be easy to maintain and extend
Acceptance Criteria:
- Clear variable naming
- Inline comments for complex logic
- Modular design (separation of concerns)
- Unit tests with >75% code coverage
NFR-003: Error Handling
Priority: High
Description: System must handle errors gracefully
Acceptance Criteria:
- API failures logged and reported to user
- Partial failures do not corrupt data
- Clear error messages for troubleshooting
- Retry logic for transient failures (optional Phase 2)
NFR-004: Security
Priority: High
Description: Docusign credentials and API calls must be secure
Acceptance Criteria:
- Credentials stored in Named Credential or Protected Custom Settings
- No hardcoded API keys
- OAuth2 or JWT authentication
- HTTPS for all API calls
3. Technical Requirements
3.1 Salesforce Platform Requirements
TR-001: Apex Version
- API version: 60.0 or higher
- Language: Apex
TR-002: Salesforce Edition
- Enterprise Edition or higher (required for API access)
- Screen Flows enabled
TR-003: Permissions
- Users must have permission to:
- Execute Flows
- Send Docusign envelopes
- Attach files to Salesforce records
3.2 Docusign Requirements
TR-004: Docusign Account
- Docusign eSignature account (Production or Sandbox)
- REST API enabled
- Composite Templates feature available
TR-005: Templates
- 28 single-form templates created:
- 14 English templates
- 14 Spanish templates
- Each template contains:
- Document with Docusign tabs
- 2 recipient roles defined
- Merge fields for Salesforce data
TR-006: API Credentials
- Integration Key (Integrator Key)
- User ID with API access
- RSA key pair (for JWT) OR OAuth2 client credentials
- Account ID (GUID)
3.3 Integration Requirements
TR-007: REST API Endpoint
- Endpoint:
/accounts/{accountId}/envelopes - Method: POST
- Request format: JSON (Composite Templates structure)
TR-008: Authentication
- Preferred: JWT (JSON Web Token)
- Alternative: OAuth2 Authorization Code Grant
- Access token refresh handling
4. User Stories
US-001: Select Forms in English
As a Salesforce user
I want to select multiple English forms to send
So that I can send all required documents in one envelope
Acceptance Criteria:
- Given I am on the form selection screen
- When I select "English" as the language
- Then I see all 14 English form templates in alphabetical order
- And I can check any combination of forms
- And I can send them in one envelope
US-002: Select Forms in Spanish
As a Salesforce user
I want to select multiple Spanish forms to send
So that I can send all required documents in one envelope in Spanish
Acceptance Criteria:
- Given I am on the form selection screen
- When I select "Spanish" as the language
- Then I see all 14 Spanish form templates in alphabetical order
- And I can check any combination of forms
- And I can send them in one envelope
US-003: Send Selected Forms
As a Salesforce user
I want to send my selected forms in one envelope
So that recipients receive all documents together
Acceptance Criteria:
- Given I have selected 3 forms
- When I click "Send"
- Then one envelope is created
- And one email is sent to recipients
- And envelope ID is returned to Salesforce
- And I see a success confirmation
US-004: View Completed Documents
As a Salesforce user
I want to see completed documents attached to the Salesforce record
So that I have a record of what was signed
Acceptance Criteria:
- Given an envelope was sent and completed
- When I view the Salesforce record
- Then I see all signed documents attached
- And I see envelope metadata (completion date, signers)
5. Constraints
5.1 Technical Constraints
- Salesforce Governor Limits: Must stay within Apex heap size (6 MB synchronous, 12 MB asynchronous), callout limits (100 per transaction), CPU time
- Docusign API Rate Limits: Respect Docusign API rate limits (varies by plan)
- Template Limit: Maximum 14 forms per envelope (business rule)
5.2 Business Constraints
- Single Language Per Envelope: Cannot mix English and Spanish in one envelope
- Same Recipients: All forms must go to the same 2 recipients
5.3 Timeline Constraints
- Delivery: Solution needed soon (target: 2-4 weeks)
6. Assumptions
- Salesforce Screen Flow already exists and displays templates
- Docusign templates are already created with correct tabs and roles
- Docusign API credentials are available (or can be configured)
- Existing document write-back logic can be reused
- Users have appropriate Salesforce and Docusign permissions
7. Dependencies
7.1 Internal Dependencies
- Salesforce Screen Flow (existing)
- Docusign templates (must be created)
- Salesforce record structure (for document attachment)
7.2 External Dependencies
- Docusign REST API availability
- Network connectivity for API callouts
8. Success Criteria
8.1 Functional Success
- ✅ Users can select any combination of forms
- ✅ All selected forms sent in ONE envelope
- ✅ Documents written back to Salesforce
- ✅ No pre-built combination templates needed
8.2 Technical Success
- ✅ Code coverage >75%
- ✅ No Salesforce governor limit violations
- ✅ Error handling tested
- ✅ API integration validated
8.3 User Success
- ✅ Easier form selection (alphabetical list vs. searching for combination)
- ✅ Faster envelope creation
- ✅ Reduced maintenance burden
9. Out of Scope (Phase 1)
The following are explicitly out of scope for the initial release:
- Custom recipient selection - recipients are fixed per template
- Dynamic tab positioning - tabs defined in templates, not runtime
- Form preview - no preview before sending
- Bulk sending - one envelope at a time
- Template versioning - template updates handled manually
- Analytics dashboard - no reporting on form selection patterns
10. Future Enhancements (Potential Phase 2)
- Dynamic recipient selection: Allow users to override default recipients
- Conditional logic: Show/hide forms based on Salesforce data
- Form preview: Preview selected forms before sending
- Bulk operations: Send envelopes to multiple records
- Template management UI: Admin UI for template configuration
- Analytics: Track which form combinations are most common
Document Status: Draft
Next Review: After design document completion
Approvers: [Customer stakeholders]