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.
{{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.
-
Retrieving a known field
{{getValue "record.email" "no-email@example.com"}}If
record.emailis"jane.doe@example.com", this outputs"jane.doe@example.com". Otherwise, it defaults to"no-email@example.com". -
Handling a dynamic field name
{{getValue (getValue "record.dynamicFieldName")}}Suppose
record.dynamicFieldNameis"promoCode", andrecord.promoCodeexists. The firstgetValuefetches"promoCode", and the second retrievesrecord.promoCode. -
Fallback for missing data
{{getValue "shipping.trackingNumber" "Not Assigned"}}If
shipping.trackingNumberdoesn’t exist or isnull, 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.
-
getValuecan fail inside a#eachblock if it cannot determine the full context path; consider referencing known fields instead, or fetch the needed value before the loop. -
Nesting
getValueallows you to build field paths at runtime, especially when you don’t know the field name in advance (e.g., date-based object keys).