# GetMergeTemplateByID - Advanced Documentation ## Overview Returns a merge template by ID with its full configuration including type, content, field mappings, and prompt definitions. Use `GetMergeTemplates` first to discover available templates. ## Caching Results are cached per template ID. Cache is invalidated when the template is saved. ## Script Example ```javascript async () => { // First find templates const templates = await SecureApi.GetMergeTemplates(); const template = templates.find(t => t.Name.includes("Demand")); if (!template) return { error: "Template not found" }; // Get full details const full = await SecureApi.GetMergeTemplateByID(template.ID); return { id: full.ID, name: full.Name, type: full.Type?.Name, fieldCount: full.Fields?.length ?? 0, fields: full.Fields?.map(f => ({ column: f.MergeColumnName, source: f.FieldSource })), promptCount: full.Prompts?.length ?? 0, prompts: full.Prompts?.map(p => ({ prefix: p.Prefix, recordType: p.RecordType })), dependsOn: full.DependentOn?.Name }; } ``` ## Prompts and the Merge Pipeline Template prompts define what data the merge engine needs beyond the template's own fields. Each prompt has a `Prefix` (label), `RecordType` (data source), and optionally a `CompanyStaffRole` (for Staff prompts). ### RecordType Interpretation The `RecordType` stored on the template prompt is **not always the RecordType used in the merge request**: | Prompt RecordType | Merge Request RecordType | RecordID | Notes | |-------------------|-------------------------|----------|-------| | `Staff` | `Staff` | Person ID | Resolve via `GetClaimStaff` matching `CompanyStaffRole.ID` | | `Contact` | **`ClaimContact`** | **ClaimContact join ID** | Must translate - call `GetClaimContacts`, match `Contact.ID`, use `ClaimContactInfo.ID` | | `FillIn` | `FillIn` | N/A | Value goes in `FillInValue` | ### Default Prompts (Not Listed in Template) Two prompts are **always required** but never appear in the template's prompt list: | Prefix | RecordType | RecordID | |--------|-----------|----------| | `Claim` | `Claim` | The Claim ID | | `Claimant` | `Contact` | The Claimant's Contact ID (from `Claim.Claimant.ID`) | See [GetMergeTemplates.md](GetMergeTemplates.md) for the full merge pipeline reference including `claim.merge` request format and all RecordType definitions. ## Error Conditions - `MergeTemplateID < 1` - throws exception - Not logged in or no company selected - throws RadoloException - Template not found in current firm - throws RadoloException - Template type not found - throws exception