Skip to main content
This guide explains how to populate and extract data from JoyDoc, focusing on text fields and table fields.

1. Accessing Fields

You can access fields using doc.fields. The fields property contains an array of all field objects in the document.

2. Finding Fields

Fields can be found using their fieldId (which is the _id property of the field).

3. Extracting Data for Non-Table Fields (Text)

At any moment, you can get the latest document from JoyDoc.onChange and extract text field values using the fieldId.

4. Populating Data

You can populate fields by injecting values into doc.fields[].value. Here’s how to populate text fields:

5. Extracting Data for Table Fields

You can get a table field value by mapping through fields and accessing the table field’s value using the table fieldId.

6. Populating Table Fields

You can populate table rows by updating the value.cells property. Here’s how to populate table fields:

Complete Example

Here’s a complete example showing both population and extraction:

Key Points to Remember

  • Field Access: Use doc.fields to access all fields
  • Field Finding: Use field._id to find specific fields
  • Text Fields: Access value directly with field.value
  • Table Fields: Access rows through field.value array, each row has cells object
  • Population: Modify field.value for text fields, or field.value[].cells for table fields
  • Extraction: Use onChange callback to get the latest document state
  • Immutable Updates: Always create new objects when updating to avoid mutation issues