salesforce-appraiser-review.../docs/SALESFORCE_SETUP.md

122 lines
5.3 KiB
Markdown

# Salesforce Setup — Appraiser Case + DocuSign CLM
> Status note (2026-04-07): the project is now standardized on `Appraiser_Case_Deficiency__c` for both UI display and CLM document generation.
## What was added
### Custom object: `Appraiser_Case__c`
- Auto-number name field labeled **Appraiser Case Number**
- Dates: `Appraiser_Field_Review_Date__c`, `Letter_Sent_Date__c`
- Appraiser identity: `Appraiser_Name__c`, `Appraiser_Last_Name__c`, `Appraiser_Salutation__c`, `Appraiser_Email__c`
- Appraiser address: `Appraiser_Street__c`, `Appraiser_City__c`, `Appraiser_State_Province__c`, `Appraiser_Postal_Code__c`, `Appraiser_Country__c`
- Property address: `Property_Street__c`, `Property_City__c`, `Property_State_Province__c`, `Property_Postal_Code__c`, `Property_Country__c`
- Case metadata: `FHA_Case_Number__c`
- CLM tracking: `Last_CLM_Account_Code__c`, `Last_DocGen_Status__c`, `Last_DocGen_Message__c`, `Last_DocGen_Task_Id__c`, `Last_DocGen_Task_Url__c`, `Last_Template_Document_Href__c`, `Last_Destination_Folder_Href__c`, `Last_DocGen_Requested_At__c`, `Last_DocGen_Completed_At__c`
- Generated document: `Generated_Document_Id__c`, `Generated_Document_Url__c`
- Attached file: `Attached_File_Content_Document_Id__c`, `Attached_File_Url__c`
### Child custom object: `Appraiser_Case_Deficiency__c`
- Master-detail to `Appraiser_Case__c`
- `Deficiency_Number__c` (Number)
- `Description__c` (Long Text Area)
- `Resolution__c` (Long Text Area)
- `Reference__c` (Text)
### Custom metadata types
- `CLM_Account_Setting__mdt` — per-account CLM and eSignature configuration (Named Credentials, folder hrefs, template hrefs)
- `CLM_Letter_Definition__mdt` — per-account letter type definitions with optional folder/template overrides
- `CLM_Environment_Setting__mdt` — legacy environment defaults (UAT/S1); superseded by account settings
### Apex classes
- `AppraiserCasePayloadBuilder.cls` + test
- `CLMDocGenCallout.cls` + test
- `CLMAdminService.cls` + test
- `DocusignESignatureService.cls` + test
### Lightning Web Components
- `clmDocGenWorkbench` — CLM document generation UI (account selection, folder browsing, merge task submission, status polling, file attachment)
- `docusignEsignWorkbench` — eSignature API browsing (accounts, templates, envelopes)
- `clmRequestPreview` — merge request preview utility
### Named credentials
- `CLMuatNamedCreds`, `CLMs1NamedCreds` — CLM API calls
- `CLMuatDownload`, `CLMs1Download` — CLM document downloads
- `Esignature_Demo_NamedCreds` — eSignature REST API
- `AcctDemo_NamedCreds` — eSignature OAuth/userinfo (**not in source; must be created manually in the target org**)
### Layouts and UI
- Page layouts for `Appraiser_Case__c` and `Appraiser_Case_Deficiency__c`
- Related list on Appraiser Case for deficiencies
- Record page: `Appraiser_Case_Record_Page`
- Quick action: `Generate Review Letter` (launches `clmDocGenWorkbench`)
- Custom tabs for both objects
- Custom app: `Appraiser_Review`
### Permissions
- `Appraiser_Case_Admin` — full access
- `Appraiser_Case_Access` — read/create access
### Sample data
- Anonymous Apex script: `scripts/apex/createSampleAppraiserCase.apex`
## Manual post-deploy steps
### Named credentials requiring org-side setup
The following are not deployable via source and must be configured in the target org:
- **`AcctDemo_NamedCreds`** — eSignature OAuth/userinfo credential referenced by `DTC_CLM_Demo` account setting. Create a Named Credential pointing to the DocuSign account server (e.g., `https://account-d.docusign.com`) with the appropriate OAuth settings.
### DocusignJWT external credential
`force-app/main/default/externalCredentials/DocusignJWT.externalCredential-meta.xml` contains demo values for `iss` (integration key) and `sub` (user GUID) targeting `account-d.docusign.com`. Replace these with your org's actual integration key and impersonation user GUID before use.
---
## Deploy
From the project root:
```bash
sf project deploy start --source-dir force-app
```
Or from elsewhere:
```bash
sf project deploy start --source-dir /home/paulh/.openclaw/workspace/projects/salesforce-appraiser-review-letter/force-app
```
## Test Apex
```bash
sf apex run test --tests AppraiserCasePayloadBuilderTest --tests CLMAdminServiceTest --tests CLMDocGenCalloutTest --tests DocusignESignatureServiceTest --result-format human
```
## Load sample data
```bash
sf apex run --file scripts/apex/createSampleAppraiserCase.apex
```
## Assign permission set
```bash
sf org assign permset --name Appraiser_Case_Admin
```
## Suggested next steps in Salesforce
1. Deploy metadata.
2. Assign permission set.
3. Run the sample Apex script.
4. Open the `Appraiser Case` tab and verify the record + related deficiencies.
5. Validate the XML merge payload path in debug logs or by running the Apex methods directly.
6. Open an `Appraiser Case` record and use the `Generate Review Letter` action to browse folders/templates and submit a merge task.
## About the quick action
The `Generate Review Letter` quick action is now wired to the `clmDocGenWorkbench` LWC for interactive CLM browsing and merge submission.
## About “page layout” and “default setup”
You said “just do default.” In Salesforce terms that means I created the baseline metadata so records can be created and edited in a normal Lightning UI without custom polish yet.