# Design — Appraiser Review Letter Generator ## Architecture Describe the template structure, merge field handling logic, and integration with Salesforce CLM. --- ## Data Model - Appraiser_Review__c: main record - Appraiser_Review_Question__c: child (per Q&A) ## Merge Data (to CLM) - Flat fields: appraiser, address, etc. - Collection: reviewQuestions[] with Q, A, comments, etc. ## Template Structure - Modular blocks (Header/Body/Footer) - Dynamic sections for deficiencies, comments, summary - Use of template language (Handlebars/Mustache/etc) ## Merge Logic - Iterate lists (arrays) for tables - Conditional display for sections/questions - Null/empty handling (default text or suppression) ## Example Structure ```handlebars {{#each DeficiencyList}} {{DeficiencyType}}{{DeficiencyDescription}} {{/each}} ``` ## CLM Template Guidance - Repeat blocks/tables for reviewQuestions - Conditional/variable blocks for rich, dynamic output --- ## Questions/Decisions - Should merge logic be handled in Salesforce or intermediary middleware? - What template engine is ideal for maintainability and troubleshooting? --- _Last updated: 2026-02-26 13:20 PM_ _Work in progress: More complete architecture diagrams and template examples forthcoming._