append

fun DocumentEditor.append(fieldId: String, targetIndex: Int, cellUpdates: Map<Column, Any?>, rowId: String? = null, schemaId: String? = null, parentPath: String? = null, metadata: Map<String, Any?>? = null)

Appends a new row to a table at a specified target index.

This function creates a new row and inserts it at the specified index position. If the target index is beyond the current number of rows, the new row will be appended at the end. The function supports both regular table fields and collection table fields.

Usage Examples:

// Insert a new row at index 0 (beginning of table)
editor.append(
fieldId = "employees_table",
targetIndex = 0,
cellUpdates = mapOf(
nameColumn to "John Doe",
ageColumn to 30.0
)
)

// Insert a deficiency row with linkage metadata
editor.append(
fieldId = "deficiency_table",
targetIndex = 0,
cellUpdates = mapOf(
descColumn to "Electrical issue"
),
metadata = mapOf(
"linkType" to "tableRowToTableRow",
"linkedPageId" to "page_source",
"linkedFieldId" to "checklist_table",
"linkedRowId" to "source_row_1"
)
)

Parameters

fieldId

The unique identifier of the table field to append to. This can be either a regular table field or a collection table field.

targetIndex

The position where the new row should be inserted. If the index is greater than the current number of rows, the row will be appended at the end.

cellUpdates

A map where keys are Column objects and values are the new cell values. The values can be of any type supported by the column (String, Number, etc.).

rowId

Optional custom identifier for the new row. If not provided, a unique ID will be generated.

schemaId

Optional schema identifier for collection fields. This is required when working with collection table fields to specify which schema to use. For regular table fields, this parameter is ignored.

parentPath

Optional parent path for nested tables in collection fields. This is used to specify the hierarchical structure when working with nested tables.

metadata

Optional metadata map for linkage info (e.g., linkedPageId, linkedFieldId, linkedRowId).

Throws

if the fieldId doesn't correspond to a valid table field.

if the targetIndex is negative.