Articles in this section

getValue helper

Use {{getValue}} to safely retrieve the value at a specified field path. If that field does not exist or is null, you can optionally provide a fallback. This helper is especially useful when field names are not fixed or are generated dynamically.

Usage

{{getValue fieldPath "defaultValue"}}
  • fieldPath: The JSON path or string identifying the field (e.g., "record.customerId" or a dynamic path from another helper).

  • defaultValue (optional): Returned if the specified field is missing or null.

Examples

  1. Retrieving a known field 

    {{getValue "record.email" "no-email@example.com"}}

    If record.email is "jane.doe@example.com", this outputs "jane.doe@example.com". Otherwise, it defaults to "no-email@example.com".

  2. Handling a dynamic field name 

    {{getValue (getValue "record.dynamicFieldName")}}

    Suppose record.dynamicFieldName is "promoCode", and record.promoCode exists. The first getValue fetches "promoCode", and the second retrieves record.promoCode.

  3. Fallback for missing data 

    {{getValue "shipping.trackingNumber" "Not Assigned"}}

    If shipping.trackingNumber doesn’t exist or is null, the helper returns "Not Assigned".

Tip

  • To avoid errors, use a default value if there’s a chance the field path might be undefined or null.

  • getValue can fail inside a #each block if it cannot determine the full context path; consider referencing known fields instead, or fetch the needed value before the loop.

  • Nesting getValue allows you to build field paths at runtime, especially when you don’t know the field name in advance (e.g., date-based object keys).