The Variable object
Variables that store temporary state.
You're viewing documentation for classic apps, which use Retool's original app editor. The new app builder is the recommended way to build apps and where Retool focuses new development.
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.
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. This method returns a promise and can only be used in JavaScript queries, not in transformers or {{ }} dynamic expressions.
await variable.setIn(options)
Parameters
Examples
Set the value of userKey in variable to userValue.
variable.setIn({keyPath: 'userKey', value: userValue});
variable.setValue(value)
Examples
Set the current value of variable to userValue.
variable.setValue(userValue);