The DataRow API provides typed access to data associated with commands in the current agent data row. It can be used from C# and JavaScript scripts to read values, update values, inspect the current list index, and check whether matching data exists.
Method names follow the conventions of each language: C# uses PascalCase and JavaScript uses lower camel case.
C#
In C#, access the current row through context.DataRow.
Example
public string GetData(RunContext context)
{
string? product = context.DataRow.GetString("Product");
int quantity = context.DataRow.GetInt("Quantity");
context.DataRow.SetBoolean("Processed", true);
return (product ?? string.Empty) + ": " + quantity;
}
Reading values
|
Method |
Returns |
Description |
|---|---|---|
|
|
|
Returns the integer value of the specified field. |
|
|
|
Returns the string value of the specified field. The result can be null. |
|
|
|
Returns the binary value of the specified field. |
|
|
|
Returns the Boolean value of the specified field. |
|
|
|
Returns the floating-point value of the specified field. |
|
|
|
Returns the date-and-time value of the specified field. |
Updating values
|
Method |
Description |
|---|---|
|
|
Sets the specified field to an integer value. |
|
|
Sets the specified field to a string value. |
|
|
Sets the specified field to a binary value. |
|
|
Sets the specified field to a Boolean value. |
|
|
Sets the specified field to a floating-point value. |
|
|
Sets the specified field to a date-and-time value. |
Other members
|
Member |
Description |
|---|---|
|
|
Gets or sets a field value without selecting a specific typed method. |
|
|
Returns the current row's list index. |
|
|
Checks whether matching data exists. Optionally restricts the comparison to the specified field names. |
C# interface
public interface DataRow
{
int GetInt(string fieldName);
string? GetString(string fieldName);
byte[] GetByteArray(string fieldName);
bool GetBoolean(string fieldName);
float GetFloat(string fieldName);
DateTime GetDateTime(string fieldName);
void SetInt(string fieldName, int value);
void SetString(string fieldName, string value);
void SetByteArray(string fieldName, byte[] value);
void SetBoolean(string fieldName, bool value);
void SetFloat(string fieldName, float value);
void SetDateTime(string fieldName, DateTime value);
object? this[string fieldName] { get; set; }
int GetListIndex();
bool DataExists(string[]? compareFieldNames = null);
}
JavaScript
JavaScript uses lower-camel-case method names. The following example accepts a DataRow instance supplied by the script context.
Example
function readAndUpdateRow(/** @type {DataRow} */ row)
{
const product = row.getString("Product");
const quantity = row.getInt("Quantity");
row.setBoolean("Processed", true);
return `${product}: ${quantity}`;
}
Reading values
|
Method |
Returns |
Description |
|---|---|---|
|
|
|
Returns the integer value of the specified field. |
|
|
|
Returns the string value of the specified field. |
|
|
|
Returns the Boolean value of the specified field. |
|
|
|
Returns the floating-point value of the specified field. |
|
|
|
Returns the date-and-time value of the specified field. |
Updating values
|
Method |
Description |
|---|---|
|
|
Sets the specified field to an integer value. |
|
|
Sets the specified field to a string value. |
|
|
Sets the specified field to a Boolean value. |
|
|
Sets the specified field to a floating-point value. |
|
|
Sets the specified field to a JavaScript |
All JavaScript setter methods return void.
Other methods
|
Method |
Returns |
Description |
|---|---|---|
|
|
|
Returns the current row's list index. |
|
|
|
Checks whether matching data exists. Optionally restricts the comparison to the supplied field names. |
JavaScript declaration
declare class DataRow {
getInt(fieldName: string): number;
getString(fieldName: string): string;
getBoolean(fieldName: string): boolean;
getFloat(fieldName: string): number;
getDateTime(fieldName: string): Date;
setInt(fieldName: string, value: number): void;
setString(fieldName: string, value: string): void;
setBoolean(fieldName: string, value: boolean): void;
setFloat(fieldName: string, value: number): void;
setDateTime(fieldName: string, value: Date): void;
getListIndex(): number;
dataExists(fieldNames?: string[]): boolean;
}
Language differences
|
Capability |
C# |
JavaScript |
|---|---|---|
|
Integer, string, Boolean, float, and date/time getters and setters |
Yes |
Yes |
|
Byte-array getter and setter |
Yes |
Not currently exposed |
|
Untyped field indexer |
Yes |
Not currently exposed |
|
Nullable string return declared by the interface |
Yes |
No |
Use the getter and setter that matches the field's configured content type.