Skip to main content

The Variable object

Variables that store temporary state.

Each instance has a unique name with which to reference (e.g., myVariable1.value).

Properties

All properties for this object with supported data types or values. You can write JavaScript almost anywhere in Retool to manipulate or read property values.

value

The value.

Type string | number | boolean | object | array
Mutability Read-only

Methods

JavaScript API methods for this object. You can write JavaScript almost anywhere in Retool and use methods to manipulate data and property values.

variable.setIn()

Set the value of a nested key.

Definition
await variable.setIn(options)
Parameters

options

The value and key-path in which to set.

Type object
Object Properties

keyPath

A list of key names that represent the hierarchical structure of a variable object when setting a value. The last item is the key on which the value is set.

Type array
Array values string

value

The value.

Type string | number | boolean | object | array


Examples

Set the value of userKey in variable to userValue.

variable.setIn({keyPath: 'userKey', value: userValue});

variable.setValue()

Set the current value.

Definition
variable.setValue(value)
Parameters

value

The value.

Type string | number | boolean | object | array

Examples

Set the current value of variable to userValue.

variable.setValue(userValue);