Skip to main content

The Utils JavaScript Library

JavaScript API methods for interacting with apps.

Use the utils JavaScript API methods to perform actions and control behavior.

utils methods are not available within transformers.

Methods

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

changeLocale

Change the user's locale.

utils.changeLocale(value)
Parameters

The value.



confetti

Display a confetti animation.

utils.confetti()

copyToClipboard

Copy the specified data to the clipboard.

utils.copyToClipboard(value)
Parameters

The value.



downloadFile

Export and download Base64-encoded data.

utils.downloadFile(downloadFileOptions)
Parameters

downloadFileOptions

object
Properties

data

any[]

The source data.


fileName

string

The file name.


fileType

string

The file extension.




downloadPage

Export and download a PDF of the current view for the app in the browser.

utils.downloadPage(fileName, downloadPageOptions)
Parameters

downloadPageOptions

object
Properties

componentsToExclude

string[]

A list of component names to exclude.


componentsToInclude

string[]

A list of component names to include.


scale

number

The resolution of the generated PDF. Defaults to the value for window.devicePixelRatio.


selectorsToExclude

string[]

A list of CSS selectors to exclude.


selectorsToInclude

string[]

A list of CSS selectors to include.



fileName

string

The file name.



exportData

Exports table data as a file in a CSV, TSV, JSON, or Excel format.

utils.exportData(exportDataOptions)
Parameters

exportDataOptions

object
Properties

data

any[]

The source data.


fileName

string

The file name.


fileType

string

The file extension.




getCurrentPosition

Retrieves the user's current geographical location, if allowed by the user.

utils.getCurrentPosition()

getDataByObjectURL

Converts the contents of a blob: or file:// URL to a Base64-encoded string. Returns a Base64-encoded string.

utils.getDataByObjectURL(value)
Parameters

The value.



openApp

Navigates to another Retool app within the organization.

utils.openApp(uuid, options)
Parameters

uuid, options



openUrl

Navigates to the specified URL.

utils.openUrl(url, openUrlOptions)
Parameters

openUrlOptions

object

Additional options to use.

Properties

forceReload

boolean

Whether to prevent client-side routing and force a page reload. Defaults to false.


newTab

boolean

Whether to open in a new tab. Performs client-side routing if false. Defaults to false.



url

string

The URL.



playSound

Plays an audio file at a specified URL. Supports all browser-compatible audio formats.

utils.playSound(url)
Parameters

url

string

The URL.



serializePage

Serializes the current Retool page as a Base64-encoded PDF string. Returns the Base64-encoded string.

utils.serializePage(serializePageOptions)
Parameters

serializePageOptions

object
Properties


showNotification

Display an in-app notification.

utils.showNotification(showNotificationOptions)
Parameters

showNotificationOptions

object

Additional options to use.

Properties

The notification body text.


duration

number

The duration that the notification should remain visible, in seconds.


notificationType

enum

The notification type to display. notificationType also determines the notification color scheme. Defaults to info.

Values
info

Info notification.

success

Success notification.

warning

Warning notification.

error

Error notification.


title

string

The notification title.