Understanding data fields

Modified on Tue, 5 May at 9:30 PM

Understanding data fields

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.

TL;DR

Access: Campaign settings → Custom fields → + New field → 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.

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));

Common searches

data field • df_ field • JSON field • structured data • array field • data field JSON • quotation lines

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article