# Next Steps ## What is done The CLM document generation workflow is fully implemented: - `clmDocGenWorkbench` quick action — account selection, letter type selection, folder browsing, template selection, generate, poll, attach - `CLMAdminService` + `CLMDocGenCallout` — full Apex service layer - All CLM tracking fields persisted back to `Appraiser_Case__c` The eSignature browsing layer is implemented (read-only): - `docusignEsignWorkbench` — accounts, templates, envelopes - `DocusignESignatureService` — login info, user info, account list, templates, envelopes --- ## Phase 2 — eSignature envelope creation The natural next step is connecting the two halves: after a CLM document is generated and attached to the case, send it for signature. ### 1. Add eSignature tracking fields to `Appraiser_Case__c` Fields needed on the case to track the envelope lifecycle: - `ESignature_Envelope_Id__c` (Text) - `ESignature_Envelope_Status__c` (Text — Created / Sent / Delivered / Completed / Voided) - `ESignature_Sent_At__c` (DateTime) - `ESignature_Completed_At__c` (DateTime) - `ESignature_Envelope_Url__c` (URL — link to envelope in DocuSign) ### 2. Add `createEnvelope()` to `DocusignESignatureService` Two approaches depending on workflow preference: **Option A — Envelope from template** Use a pre-built eSignature template. Recipients and document are defined in the template; Salesforce passes merge data (tabs) at send time. ```apex // POST /v2.1/accounts/{accountId}/envelopes // body: { templateId, templateRoles: [{ email, name, roleName }], status: 'sent' } ``` **Option B — Envelope from uploaded document** Use the CLM-generated document (already attached to the case as a ContentVersion). Download the blob and POST it directly as an envelope document. ```apex // POST /v2.1/accounts/{accountId}/envelopes // body: { documents: [{ documentBase64, name, fileExtension, documentId }], // recipients: { signers: [...] }, status: 'sent' } ``` Option A is simpler if a matching eSignature template exists. Option B gives more control but requires managing recipient configuration in code. ### 3. Persist envelope result to `Appraiser_Case__c` On success, write the envelope ID, status, and sent timestamp back to the case (same pattern as `CLMAdminService.persistDocGenResult`). ### 4. Add send action to `clmDocGenWorkbench` After "Attach Generated Document" succeeds, enable a "Send for Signature" button that calls the new `createEnvelope()` method. Show envelope status alongside the existing task status display. ### 5. Add envelope status polling (optional) Mirror the CLM task status pattern: a "Check Signature Status" button that calls `GET /v2.1/accounts/{accountId}/envelopes/{envelopeId}` and updates the case. --- ## Phase 3 — Additional letter types Three letter types are defined in `CLM_Letter_Definition__mdt` but have no CLM templates yet: - `NOD_LETTER` — Notice of Deficiency - `EDUCATION_LETTER` — Education correspondence - `INTENT_TO_REMOVE_LETTER` — Intent to Remove notification For each: 1. Build the CLM template `.docx` and upload to the CLM account 2. Update the `Default_Template_Document_Href__c` in the corresponding `CLM_Letter_Definition__mdt` records 3. Confirm whether deficiency display or field set differs from the appraiser review letter (if so, extend `AppraiserCasePayloadBuilder`) --- _Last updated: 2026-04-09_