# GetClaimContacts - Advanced Notes ## Response Structure Returns an array of `ClaimContactInfo` objects. Each entry's `ID` is the claim-contact link, not the person or company; the person or company is under `Contact` (`Contact.ID`, `Contact.Name`). The role is `ContactType.Name`. AdHocFields is where insurance details, adjuster references, policy numbers, and similar custom data live. ## Reading Ad Hoc Fields Ad hoc fields vary by firm and contact type. Each field has a `FieldLabel` and a `DataType`. Read the value only from the property that matches its `DataType`. `FieldValue` is always ignored. ```javascript const VALUE_PROP = { 'TextShort': 'TextShortValue', 'Hyperlink': 'TextShortValue', 'TextLong': 'TextLongValue', 'Dropdown': 'DropdownValue', 'State': 'DropdownValue', 'Number': 'NumberValue', 'Decimal': 'DecimalValue', 'Date': 'DateValue', 'DateTime': 'DateTimeValue', 'Yes/No': 'YesNoValue', 'Contact': 'BaboContact', 'Staff': 'Staff', 'Document': 'Document' }; const readAdHoc = f => { const prop = VALUE_PROP[f.DataType]; if (!prop) throw new Error(`Unmapped ad hoc DataType: ${f.DataType}`); const v = f[prop]; // Contact, Staff and Document values are references; use their Name return (v && typeof v === 'object' && 'Name' in v) ? v.Name : v; }; contact.AdHocFields.forEach(f => { const val = readAdHoc(f); if (val) result[f.FieldLabel] = val; }); ``` ## AdHocFieldDefinitionID and Round-Tripping into SaveClaimContact Each item in `AdHocFields` also carries a real `AdHocFieldDefinitionID`, read directly from the database - it is not a placeholder and is never 0. When passing an `AdHocFieldInfo` back into `SaveClaimContact`, preserve the `AdHocFieldDefinitionID` you received from `GetClaimContacts` unchanged; there is no need to look it up again via `GetAdHocFieldDefinitionsContactType`. ## Common Insurance Company Ad Hoc Fields On "Insurance Company" contacts, you'll typically find: - **Adjuster** - `BaboContact` reference to the adjuster person - **Insured** - name of the insured party - **Policy Number** - the insurance policy number - **Claim Number** - the insurance claim number - **Type of Insurance** - coverage type (Liability, UM, MedPay, Excess, etc.) - **Limits** - policy limits - **LOR Requested** / **LOR Sent** - letter of representation dates - **Insurance Note** - additional contact info or notes ## Script Example ```javascript async () => { const contacts = await SecureApi.GetClaimContacts(771360); return contacts .filter(c => c.ContactType.Name === 'Insurance Company') .map(c => { const adhocs = {}; c.AdHocFields.forEach(f => { const val = readAdHoc(f); // readAdHoc from "Reading Ad Hoc Fields" above if (val) adhocs[f.FieldLabel] = val; }); return { carrier: c.Contact.Name, ...adhocs }; }); } ```