Get Row
Retrieves a specific row from a DataTable by its zero-based index. The row is returned as a dictionary object with column names as keys and cell values as values.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Input
- Table - DataTable to get the row from
- Row Index - Zero-based index of the row to retrieve (0 = first row, 1 = second row, etc.)
Output
- Row - Dictionary object containing the row data with column names as keys
Example Usage
Retrieving the First Row
// Table with columns: ["ID", "Name", "Email"]
// Row 0: ID=1, Name="John Doe", Email="john@example.com"
// Row 1: ID=2, Name="Jane Smith", Email="jane@example.com"
var rowIndex = 0; // First row
// Output row object:
// {
// "ID": 1,
// "Name": "John Doe",
// "Email": "john@example.com"
// }
Accessing Row Data
// Get row
var rowIndex = 0;
var row = /* Get Row output */;
// Access individual values
var id = row["ID"]; // 1
var name = row["Name"]; // "John Doe"
var email = row["Email"]; // "john@example.com"
// Use the values
console.log("Processing user: " + name);
Processing Rows in a Loop
// Assume table has 10 rows
var totalRows = 10;
for (var i = 0; i < totalRows; i++) {
// Get Row node with rowIndex = i
var row = /* Get Row output */;
// Process each row
var name = row["Name"];
var email = row["Email"];
// Send email, update database, etc.
}
Getting the Last Row
// Get table row count first (from table.rows.length or store it)
var rowCount = 100;
var rowIndex = rowCount - 1; // Last row (99)
var row = /* Get Row output */;
// Returns the last row in the table
Conditional Processing Based on Row Data
// Get a specific row
var rowIndex = 5;
var row = /* Get Row output */;
// Check conditions
if (row["Status"] === "Active") {
// Process active record
var email = row["Email"];
// Send notification
}
if (row["Age"] > 18) {
// Process adult records
}
Comparing Rows
// Get two rows for comparison
var rowIndex1 = 0;
var row1 = /* Get Row output */;
var rowIndex2 = 1;
var row2 = /* Get Row output */;
// Compare values
if (row1["Email"] === row2["Email"]) {
// Duplicate email found
console.log("Duplicate detected");
}
Extracting Row for Update
// Get row to modify
var rowIndex = 3;
var row = /* Get Row output */;
// Modify values
row["Status"] = "Processed";
row["UpdatedDate"] = new Date().toISOString();
// Use modified row with Add Row node (after removing original)
// Or update external database
Tips
- Row indices are zero-based: first row is index 0
- The output is a dictionary with column names as keys
- All columns in the row are included in the output object
- To get the row count, access the table's rows array length
- For iterating all rows, use a loop with incrementing row index
- Values preserve their original data types (strings, numbers, objects)
- Missing or null values are included as null or empty
Common Errors
Empty Table Error
Error: Table cannot be empty. Please provide a valid DataTable.
Solution: Ensure you're passing a valid DataTable object.
// Wrong - table is null or undefined
var table = null;
// Correct
var table = /* Valid DataTable from Create DataTable or other source */;
Negative Row Index Error
Error: Row index must be greater than or equal to zero. Current value: -1
Solution: Provide a non-negative row index.
// Wrong
var rowIndex = -1;
// Correct
var rowIndex = 0; // First row
Index Out of Bounds Error
If you specify a row index that exceeds the number of rows in the table, you'll get an index out of bounds error.
// Table has 10 rows (indices 0-9)
// Wrong - index 10 doesn't exist
var rowIndex = 10; // Error!
// Wrong - index 100 is too large
var rowIndex = 100; // Error!
// Correct
var rowIndex = 9; // Last row (10th row, index 9)
Solution: Ensure the row index is less than the total number of rows.
// Check row count first
var table = /* DataTable */;
var rowCount = table.rows.length;
// Use valid index
var rowIndex = 0; // or any value from 0 to (rowCount - 1)
if (rowIndex >= 0 && rowIndex < rowCount) {
// Safe to get row
var row = /* Get Row output */;
}
Empty Table (No Rows)
Getting a row from a table with no rows will cause an error.
// Table with 0 rows
var rowIndex = 0;
// Error: index out of bounds
// Solution: Check if table has rows first
if (table.rows.length > 0) {
var row = /* Get Row */;
}
See Also
- Get Column - Retrieve entire columns
- Add Row - Add new rows
- Remove Row - Remove rows by index
- Filter DataTable - Filter rows by condition
- Lookup DataTable - Search for rows by value