# SaveLeadIntegration - Advanced Documentation ## Overview Creates or updates a lead integration and its field mappings. Field mappings decide which value in a posted lead fills which intake field when an intake is created from the lead. ## Read First Before creating or changing a lead integration, read help page "Lead Integration Setup" via `GetHelp(TitleFilter: "Lead Integration Setup")`. It covers the public lead-post URL (`HandleLeadNotification`), the required ClientID, the rule that SourceOfContact must exactly match a source registered on the integration, the fields mapped automatically, and the date formats. The lead-post endpoint is not callable through these tools. ## Business Rules - **New integration**: `ID` less than 1 creates a new integration and generates its ClientID. - **Mapping sync**: `FieldMappings` is synced on save. Matching mappings are updated, new ones are added, and existing mappings missing from the list are removed. An empty or omitted (null) list removes all mappings. Always send the full mapping list. - **Path validation**: every mapping's `ClaimFieldValueString` must be the `ValueString` of a field that `GetFieldsForClaimTypeIntake` or `GetFieldsForContact` returns for your firm, excluding Staff, Contact, and SystemDropdown fields. Otherwise the save is rejected with an error naming the bad mapping (for example a bare field ID like `12345`, or a path for a field your firm does not have). The formats in "ClaimFieldValueString Formats" describe what those fields look like. ## LeadFieldMappingInfo Properties - `ID`: mapping record ID. Use `-1` for a new mapping. - `LeadField`: dot path to the value in the posted lead, not including the lead's root element. Nested elements use dots (for example `Address.City`). Exact case. A missing or empty value skips the mapping. - `ClaimFieldValueString`: the target field path. Take it from the `ValueString` of a field returned by `GetFieldsForClaimTypeIntake` (claim fields) or `GetFieldsForContact` (contact fields). Never a bare field ID. - `ClaimFieldName`: display label. Each mapping in an integration needs a different target field. - `DataType`: must equal the target field's `DataType` from the same field record. It controls how the lead value is converted. ## ClaimFieldValueString Formats A path is valid only if it is one the lead integration field pickers offer. Any other path is rejected on save with an error naming the bad mapping. The valid formats are: - **System claim field**: `claim.`, for example `claim.IntakeNotes`, `claim.StatuteOfLimitations`, `claim.EstimatedValue`, `claim.AlternateReferenceNumber`. - **Claim group field**: `claim.ClaimGroup.`, for example `claim.ClaimGroup.Synopsis`, `claim.ClaimGroup.IncidentDate`. - **Claimant contact field**: `contact.`, for example `contact.FirstName`. - **Nested contact field**: `contact..`, for example `contact.Representative.ID`. - **Custom claim field or custom contact field**: `claim.AdHocFields[].Value` or `contact.AdHocFields[].Value`, for example `claim.AdHocFields[12345].TextShortValue`. Suffixes: `TextShortValue`, `TextLongValue`, `NumberValue`, `DecimalValue`, `DateValue`, `DateTimeValue`, `YesNoValue`. Hyperlink uses `TextLongValue`. State uses `TextShortValue`. - **Custom dropdown field**: `claim.AdHocFields[]` or `contact.AdHocFields[]` with `DataType` "Dropdown". Do not add `.DropdownValue`. - **Custom document field**: `claim.AdHocFields[].Document` or `contact.AdHocFields[].Document`. - **SSN**: exactly `contact.SocialSecurityNumber`. Send the lead value as `123-45-6789` or as 9 digits with no separators. Any other separator puts the whole value in the first part. ## Supported Data Types - Supported: Date, DateTime, Yes/No, Dropdown, TextLong, TextShort, Decimal, Number, Hyperlink. - Not supported: Contact, Staff, SystemDropdown. The field pickers do not offer these types, so a mapping to one of them (custom Staff or Contact fields, `claim.Rank`, `claim.HowDidYouHearAboutUs`, `claim.ReferredBy`, `contact.Language.ID`) is rejected on save. - State and Document fields are offered, so a mapping to one is saved, but the lead value is not applied to them when an intake is created from the lead (the mapping is skipped).