Commit Graph

23 Commits

Author SHA1 Message Date
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
Paul Huliganga 9b355b997e feat(apex): support multiple copies of Authorization to Release Information
DocusignEnvelopeRequest:
- Add authReleaseFormCopies InvocableVariable (Integer, optional, 1-3)

DocusignCompositeEnvelopeBuilder:
- Add MULTI_COPY_TEMPLATE_NAME constant (single place to update if the
  template is renamed; matched via LIKE '%...%' covering both languages)
- Before building the document list, query for template IDs matching the
  multi-copy template name and append (copies-1) additional IDs so the
  envelope contains the correct number of distinct documents
- Duplicate-safe label builder: appends '(Copy N)' suffix to keep
  document labels unique within the envelope
- Build deduplicated displayNames list for email subject/body:
  collapses multi-copy entries to a single line with a '(N)' count
  suffix, e.g. 'Authorization to Release Information (3)'
- Email body: each template's message text is included only once even
  when the same template ID appears multiple times (bodyIdsAdded guard)
- Log and Status label use displayNames (deduplicated) not raw docNames
2026-03-11 16:23:51 -04:00
Paul Huliganga 81c08f3fe1 feat(flow): add multi-copy dialog for Authorization to Release Information
When the 'Authorization to Release Information' template (English or
Spanish) is selected, a new screen prompts the user to choose how many
copies (1, 2, or 3) to include in the envelope via radio buttons.

New flow elements:
- Scan_For_Auth_Release_Template loop: iterates selected rows to detect
  the target template
- Does_Row_Contain_Auth_Release decision: Contains check on row Name
- Flag_Auth_Release_Selected assignment: sets authReleaseTemplateSelected
- Is_Auth_Release_Selected decision: routes to copies screen or skips
- Authorization_Copies_Screen: displays radio buttons (1/2/3 copies)
- Store_Auth_Release_Copies assignment: writes radio selection into the
  authReleaseFormCopies flow variable
- authReleaseFormCopies variable (Number, default 1)
- authReleaseTemplateSelected variable (Boolean, default false)
- AuthCopies_1/2/3 choices

authReleaseFormCopies is passed to the Apex action as a new input param.
Template name string lives in a single Contains condition for easy update.
2026-03-11 16:23:32 -04:00
Paul Huliganga 30fc345bb0 Sort templates alphabetically by Short_Name__c in email subject and document order
- Updated DocusignCompositeEnvelopeBuilder.cls to sort documents and subject by Short_Name__c
- Modified Docusign_Envelope_Templates_V3.flow-meta.xml: repositioned elements and added filter for Short_Name__c not null
2026-03-03 23:12:06 -05:00
Paul Huliganga 61446bde23 Fix email subject truncation to 100 chars
- Add truncation to existing working email subject logic (combined template names)
- Subject is truncated to 100 characters max with '...' suffix when needed
- Add test case for truncation with multiple templates
- Preserves existing behavior: subject = combined template names, body = concatenated email messages
2026-03-03 18:55:18 -05:00
Paul Huliganga 32369c5939 Fix email subject to use combined template Short Names
- Query Short_Name__c field from dfsle__EnvelopeConfiguration__c
- Use short names for email subject (fallback to full names if blank)
- Custom emailSubject still overrides if provided
- Always truncate subject to 100 characters max
- Fixes issue where selecting all templates created too-long subject
2026-03-03 18:51:42 -05:00
Paul Huliganga 90c65ea2c6 Fix email subject truncation to 100 chars
- Truncate req.emailSubject to 100 characters max as required by Docusign
- Add '...' suffix when truncating long subjects
- Add test case for subject truncation validation
- Fixes error: 'email subject must be no greater than 100 characters'
2026-03-03 18:38:00 -05:00
Paul Huliganga 9a8cde3735 Fix email subject truncation to 100 chars
- Truncate envelopeSubject to 100 characters max as required by Docusign
- Add '...' suffix when truncating long subjects
- Add test case for subject truncation validation
- Fixes error: 'email subject must be no greater than 100 characters'
2026-03-03 17:40:47 -05:00
Paul Huliganga 95abbdbabd Revert "Fix email subject truncation to 100 chars"
This reverts commit 458d8f21a4.
2026-03-03 17:40:34 -05:00
Paul Huliganga 458d8f21a4 Fix email subject truncation to 100 chars
- Truncate envelopeSubject to 100 characters max as required by Docusign
- Add '...' suffix when truncating long subjects
- Add test case for subject truncation validation
- Fixes error: 'email subject must be no greater than 100 characters'
2026-03-03 17:24:36 -05:00
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
Paul Huliganga 03a8f48e8d feat: envelope uses combined template names for subject and concatenated dfsle_EmailMessage__c for body
- Email subject is now combined document names (Short_Name__c if available)
- Email body is concatenated dfsle_EmailMessage__c from each selected template
- No longer uses template-level email subject for envelope
- Keeps status/document name logic unchanged
2026-02-25 23:55:30 -05:00
Paul Huliganga 5ae3da3c1e feat: use Short_Name__c for Document Name when available
Priority: Short_Name__c > stripped Name > template ID
Requires adding Short_Name__c (Text 80) custom field to
dfsle__EnvelopeConfiguration__c. Falls back to language-stripped
Name if Short_Name__c is blank or not populated.
2026-02-25 17:44:15 -05:00
Paul Huliganga fed796e6cc feat: concatenate template names for Document Name, strip language suffix
- First document label is now all template names joined with ', '
- Strips ' - English', ' - Spanish', ' - French' suffixes (case-insensitive)
- Truncates to 255 chars with '...' if too long
- Docusign Status now shows e.g. 'Admin Unit Notification, Consent to Eval'
  instead of 'Template 89dd5ead'
2026-02-25 17:33:42 -05:00
Paul Huliganga 978051bf49 fix: use actual template names for Document Name in Docusign Status
Query dfsle__EnvelopeConfiguration__c to get template names and pass
them as document labels to dfsle.Document.fromTemplate(). This makes
the Docusign Status screen show meaningful names like 'Consent to Eval'
instead of 'Template 89dd5ead'.
2026-02-25 17:17:40 -05:00
Paul Huliganga 4211648e2a feat: add recipient resolution from Client_Case__c lookup fields
- Queries Client_Case__c for Service_Coordinator__c and Docusign_Recipient_1__c
- Resolves Contact/User name and email from lookup targets
- Maps recipients to Docusign template roles: 'Service Coordinator' and 'Docusign Recipient #1'
- Validates recipients exist and have email addresses
- Supports both Contact and User lookup types
- Role names and field names are configurable constants at top of class
- Clear error messages if recipients are missing or have no email
2026-02-25 12:28:08 -05:00
Paul Huliganga 4b1edd4d27 refactor: switch to dfsle Apex Toolkit - remove raw API code
BREAKING CHANGE: Now uses dfsle managed package for Docusign integration.
No separate credentials or Named Credentials needed.

Changes:
- Rewrote DocusignCompositeEnvelopeBuilder to use dfsle.EnvelopeService
  and dfsle.Document.fromTemplate() for composite envelopes
- Simplified DocusignEnvelopeRequestHandler to validation-only
- Updated all tests to use dfsle.TestUtils.setMock()
- 12 comprehensive test methods (success, validation, edge cases)

Deleted (no longer needed):
- DocusignAPIService.cls (raw HTTP callouts)
- DocusignAPIServiceTest.cls
- DocusignCredentials.cls (custom settings)
- DocusignCredentialsTest.cls

Benefits:
- Uses existing dfsle package authentication automatically
- No Named Credential or Custom Setting setup required
- ~95 lines of code vs ~380 lines before
- Fully supported by Docusign managed package
2026-02-25 11:29:38 -05:00
Paul Huliganga ace2518349 fix: reorder V3 Flow XML elements - group same types together
Salesforce requires elements of the same type (recordLookups, decisions,
screens, etc.) to be grouped together. Reordered all elements alphabetically
by type to comply with Flow metadata schema.
2026-02-25 11:06:40 -05:00
Paul Huliganga 19852fd4bb fix: move flow XML files to correct force-app/main/default/flows/ directory 2026-02-25 11:03:10 -05:00
Paul Huliganga 7df62e06ca refactor: extract Request and Result as standalone global classes
- Created DocusignEnvelopeRequest.cls (separate global class for input)
- Created DocusignEnvelopeResult.cls (separate global class for output)
- Updated DocusignCompositeEnvelopeBuilder to use standalone classes
- Updated DocusignEnvelopeRequestHandler to reference standalone classes
- Updated all test classes to use new class references
- Fixes Flow Builder visibility issues with nested inner classes
- Better API design with clear input/output types
- Easier to extend and reuse across other classes
2026-02-25 10:05:36 -05:00
Paul Huliganga b00a930e8d fix: remove duplicate JSON builder test from main class
- Removed testJSONBuilder from DocusignCompositeEnvelopeBuilderTest
- JSON building logic tests now handled by DocusignEnvelopeRequestHandlerTest (10 comprehensive tests)
- Fixes deployment error: method buildCompositeEnvelopeJSON no longer exists in main class
- Eliminates code duplication between test classes
2026-02-25 09:39:18 -05:00
Paul Huliganga 2f7dcf3520 refactor: extract request handling to global DocusignEnvelopeRequestHandler class + deployment guide
Changes:
- Move validation logic to DocusignEnvelopeRequestHandler.validateRequest()
- Move envelope JSON building to DocusignEnvelopeRequestHandler.buildEnvelopeJSON()
- Add comprehensive test suite for handler (10 test methods)
- Simplify main invocable method - focus on orchestration
- Add DEPLOYMENT_AND_TESTING.md reference guide with all CLI commands
- Handler is reusable for future enhancements and integrations

Benefits:
- Single Responsibility Principle
- Reusable handler for other classes
- Better testability
- Clean separation of concerns
2026-02-25 09:32:55 -05:00
Paul Huliganga 4f734f0d17 Initial commit: Salesforce Composite Envelope Builder 2026-02-25 09:22:29 -05:00