Record variable
- Updated: 2020/10/19
A record variable holds a row of data extracted from a database, spreadsheet, or table in name-field pairs. The fields can store values of Boolean, datetime, number, or string data type.
Working with a record variable
Record variables are commonly used in the loop action to store a single row of retrieved data; you can access a single value by specifying the index number or name. The index number is the position of the name-field pair. The name is either configured when the variable is initialized or it can be extracted from the column headers of the source table.
The following is an example table:
CustomerName | City |
---|---|
Dana | Pittsburgh |
Sam | Los Angeles |
Alex | Boston |
rCurrentRow
. To retrieve the value from the first
column of each row, use either the index number $rCurrentRow[0]$
or
name $rCurrentRow{CustomerName}$
.Schema
A schema is like a template for the record fields. It sets the order of the fields and the type of data that can be entered into each field.
- The retrieved values must match the configured field data types.
For example, the data set
[{"name":"Sally"},{"id":002},{"dob":03/05/1989}]
can be assigned to a record variable with the schema[{"name":String},{"id":Number},{"dob":Date}]
. - The data set attributes must follow the same order and capitalization.
For example, the data set
[{"name":"Henry"},{"id":003},{"dob":06/13/2001}]
cannot be assigned to a record variable with the schema[{"id":Number},{"name":String},{"dob":Date}]
or{"Name":String},[{"ID":Number},{"DOB":Date}]
. - The record variable can accept a superset of the configured fields if the
fields are in the same order.
For example, the data set
[{"name":"Alex"},{"id":004},{"dob":12/10/1995},{"pet":"yes"}]
can be assigned to a record variable with the schema[{"name":String},{"id":Number},{"dob":Date}]
. - The record variable does not accept a subset of data.
For example, the data set
[{"id":005},{"dob":05/21/1975}]
cannot be assigned to a record variable with the schema[{"name":String},{"id":Number},{"dob":Date}]
.
If the bot encounters a row of data that does not meet the record variable schema, the bot fails. This prevents the bot from passing incorrect or invalid data into the next action.