Skip to content

Add Data Row

Type: add-row  ·  Package: DataTable Activities v1.0.5  ·  Output: DataRow

Appends a new row at the end of a DataTable and returns the created row.

Creates a row with the values you provide and appends it to the table. It returns the created DataRow, so you can keep working on it with Set Cell or Update Data Row.

The values are given in two ways (a toggle in the editor):

  • By column — a { column: value } dictionary. Order-independent; each name must be an existing column. Columns you don’t mention are left empty.
  • By position — a list of values in column order. You must provide exactly one value per column.

Each value is converted to its column type (for example, "25" to int). A null or an empty string is stored as an empty cell (DBNull). All values are validated before the row is added: if one fails, the table stays as it was.

ParameterTypeDefaultDescription
tableDataTable—The DataTable the row is added to, e.g. customers.
valuesDictionary | List—The row values, by column { column: value } or by position [v1, v2, …]. Each value accepts a literal or an expression.

None.

Returns the newly created DataRow, already part of the table.

MessageCause and fix
'table' must be a DataTable.table does not evaluate to a DataTable.
Column '…' does not exist. Available columns: ….A dictionary key is not a column of the table. The message lists the real columns.
… value(s) provided but the table has … column(s). When passing a list, provide exactly one value per column, in column order.In by-position mode, the list does not have one value per column. Use null for the ones you want empty.
A value is not compatible with the type '…' of column '…'.A value cannot be converted to the column type (text in a numeric column, for example). Convert the value first or check the column type.
'values' must be an object { column: value } or a list of values.values is neither a dictionary nor a list (for example, a plain text).

Build a table and add rows in two ways:

Build DataTable data: [ { id: 1, name: "Ana", age: 30 } ] → output: people
Add Data Row table = people values (by column): { id: 2, name: "Luis", age: 25 } → output: row
Add Data Row table = people values (by position): [ 3, "Carla", 28 ]
Log message = "The table has " + rowCount(people) + " rows; the new one belongs to " + str(row["name"])