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
Change the user's locale.
utils.changeLocale(locale)
Parameters
Examples
"en"
Examples
Change the locale to en
.
utils.changeLocale('en');
utils.confetti
Display a confetti animation.
utils.confetti()
Examples
Display a confetti animation.
utils.confetti();
utils.copyToClipboard
Copy the specified data to the clipboard.
utils.copyToClipboard(data)
Examples
Copy the value of textInput1.value
to the clipboard.
utils.copyToClipboard(textInput1.value);
utils.downloadFile
Download the specified data as a file. data
can be a string for plain text data or an object containing base64-encoded binary data.
utils.downloadFile(data, fileName, fileType)
Parameters
Examples
Download a text file.
utils.downloadFile('Hello World', 'hello-world', 'txt');
Download a JPEG file.
utils.downloadFile({data: {base64Binary: 'iVBORw0KGgoAAAANSU...'}}, 'image', 'jpeg');
utils.downloadPage
Export and download a PDF of the current view for the app in the browser.
utils.downloadPage(options)
Parameters
Object Properties
utils.exportData
Exports data as a file in a CSV, TSV, JSON, or Excel format.
utils.exportData(options)
utils.getCurrentPosition
Retrieves the user's current geographical location, if allowed by the user.
await utils.getCurrentPosition()
Returns
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)
utils.openApp
Navigates to another Retool app within the organization.
utils.openApp(uuid, options)
Parameters
Object Properties
utils.openPage
Navigates to another page within the app.
utils.openPage(pageName)
utils.playSound
Plays an audio file at a specified URL. Supports all browser-compatible audio formats.
utils.playSound(url)
utils.serializePage
Serializes the current Retool page as a Base64-encoded PDF string. Returns the Base64-encoded string.
utils.serializePage()
utils.showNotification
Display an in-app notification.
utils.showNotification(options)
Parameters
Object Properties
notificationType
The notification type to display. notificationType
also determines the notification color scheme. Defaults to info
.
Type | string | ||||||||||
Allowed Values |
|