The Utils JavaScript Library
JavaScript methods for interacting with apps.
Use the utils
JavaScript API methods to perform actions and control behavior.
These methods are not available within transformers or workflows.
JavaScript API methods for this object. You can write JavaScript almost anywhere in Retool and use methods to manipulate data and property values.
utils.changeLocale(locale)
Parameters
locale
The locale.
Examples
Change the locale to en
.
utils.changeLocale('en');
utils.confetti()
Examples
Display a confetti animation.
utils.confetti();
utils.copyToClipboard(data)
Parameters
data
The data to copy, formatted as a string.
Examples
Copy the value of textInput1.value
to the clipboard.
utils.copyToClipboard(textInput1.value);
utils.downloadFile(options)
Parameters
options
utils.downloadPage(options)
Parameters
options
Object Properties
componentsToExclude
A list of component names to exclude.
componentsToInclude
A list of CSS selectors to include.
fullscreen
Whether to generate a PDF using presentation mode. Defaults to false
.
scale
The resolution of the generated PDF. Defaults to the value for window.devicePixelRatio
.
selectorsToExclude
A list of CSS selectors to exclude.
selectorsToInclude
A list of CSS selectors to include.
utils.exportData(options)
Parameters
options
utils.getCurrentPosition()
Retrieves the user's current geographical location, if allowed by the user.
await utils.getCurrentPosition()
Examples
Get the user's current position.
utils.getCurrentPosition();
utils.getDataByObjectURL()
Converts the contents of a blob:
or file://
URL to a Base64-encoded string. Returns a Base64-encoded string.
utils.getDataByObjectURL(data)
Parameters
data
The data to convert.
utils.openApp(uuid, options)
Parameters
uuid
The UUID (Universally Unique Identifier).
options
Object Properties
hashParams
The value to append as a hash parameter. Only one hash property can be included but it can contain multiple key-value pairs.
newTab
Whether to open in a new tab. Performs client-side routing if false
. Defaults to false
.
queryParams
Key-value pairs to include as URL query parameters.
utils.openUrl(url, options)
Parameters
url
The URL.
options
Object Properties
forceReload
Whether to prevent client-side routing and force a page reload. Defaults to false
.
newTab
Whether to open in a new tab. Performs client-side routing if false
. Defaults to false
.
utils.playSound()
Plays an audio file at a specified URL. Supports all browser-compatible audio formats.
utils.playSound(url)
Parameters
url
The URL.
utils.serializePage()
Serializes the current Retool page as a Base64-encoded PDF string. Returns the Base64-encoded string.
utils.serializePage()
utils.showNotification(options)