# Understanding data fields

URL: https://help.hubhus.com/kb/understanding-data-fields
Category: Data & Custom Fields / Data fields
Updated: 2026-09-28T14:40:57.218+00:00

Summary: Access: Campaign settings → Data fields → + New data field . Data fields store JSON in a lead record. Slug always starts with df_ . Write via: jQuery('#df_slug').val(JSON.stringify(data)) . Read via hh-data-fields.value component on webpages. Define a JSON Schema to validate structure. Use for: quotation lines, selected products, multi-step form data, calculation results.

Data fields are JSON-based custom fields that store structured data - arrays, objects, or nested values - per lead. Unlike regular text fields, data fields can hold multiple items, making them ideal for price calculations, product selections, multi-step form results, and anything that requires structured data storage.

## 4 things to understand

1. **What data fields store**. A data field stores a single JSON value per lead - typically an array of objects (e.g. a list of selected products) or a single object (e.g. calculation results). The slug always starts with `df_` (e.g. `df_quotation_lines`, `df_selected_products`). The field is empty until something writes a JSON value to it via JavaScript or an HTTP request JSON map.
2. **Writing to a data field**. In a Hubhus form or webpage, write to the field using jQuery: `jQuery('#df_slug').val(JSON.stringify(yourData))`. The hidden input with `id="df_slug"` is injected by Hubhus - use this ID to set the value before form submission. Data is only saved when the form is submitted (or auto-saved). Always stringify the data before setting the value.
3. **Reading data fields on webpages**. On campaign webpages (display to lead), use the `hh-data-fields.value` component to render data field values: `<hh-data-fields.value field="df_slug" />`. For structured data (arrays), use `hh-data-fields.array` with a template for each item. In email/SMS templates, use `{{df_slug}}` or iterate via template loops.
4. **JSON Schema validation**. Define a JSON Schema on the field to validate the structure of stored data. Hubhus validates against the schema on save - invalid data is rejected. This prevents bad data from entering the system. Schema also enables autocomplete in the Hubhus playground. Important: never make a breaking schema change (e.g. removing or renaming keys) on a field with existing lead data - old values must remain valid, or perform a conscious migration.

**Read more**

Common use cases

- **Quotation line generator:** Store an array of selected products/services per lead, render as a price table on a webpage
- **Multi-step form results:** Accumulate answers across multiple form steps into one structured field
- **Calculation outputs:** Store intermediate and final calculation results for display on confirmation pages
- **External API responses:** Write structured data from HTTP request JSON maps back into a data field

Example: writing an array

```
var lines = [
  { name: 'Produkt A', qty: 2, price: 499 },
  { name: 'Produkt B', qty: 1, price: 199 }
];
jQuery('#df_quotation_lines').val(JSON.stringify(lines));
```

## Related articles

- https://help.hubhus.com/kb/how-do-i-create-custom-fields
- https://help.hubhus.com/kb/working-with-data-fields-in-bookingforms-advanced-json-storage
- https://help.hubhus.com/kb/using-signature-sketch-fields-for-digital-signatures
- https://help.hubhus.com/kb/creating-a-quotation-line-generator-with-visual-presentation
- https://help.hubhus.com/kb/hh-components-reference-guide
- https://help.hubhus.com/kb/campaign-webpages-and-webpage-forms-displaying-data-to-leads
