Add Data Row
Add Data Row
Section titled “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.
How it works
Section titled “How it works”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.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
table | DataTable | — | The DataTable the row is added to, e.g. customers. |
values | Dictionary | List | — | The row values, by column { column: value } or by position [v1, v2, …]. Each value accepts a literal or an expression. |
Optional parameters
Section titled “Optional parameters”None.
Output
Section titled “Output”Returns the newly created DataRow, already part of the table.
Common errors
Section titled “Common errors”| Message | Cause 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). |
Example
Section titled “Example”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: rowAdd 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"])Related activities
Section titled “Related activities”- Build DataTable — create the table to add rows to.
- Set Cell / Update Data Row — modify the returned row.
- Data types › DataRow — what a row is.