1. Accessing Fields
You can access fields usingdoc.fields. The fields property contains an array of all field objects in the document.
2. Finding Fields
Fields can be found using theirfieldId (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 fromJoyDoc.onChange and extract text field values using the fieldId.
4. Populating Data
You can populate fields by injecting values intodoc.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’svalue using the table fieldId.
6. Populating Table Fields
You can populate table rows by updating thevalue.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.fieldsto access all fields - Field Finding: Use
field._idto find specific fields - Text Fields: Access value directly with
field.value - Table Fields: Access rows through
field.valuearray, each row hascellsobject - Population: Modify
field.valuefor text fields, orfield.value[].cellsfor table fields - Extraction: Use
onChangecallback to get the latest document state - Immutable Updates: Always create new objects when updating to avoid mutation issues