Skip to main content

Run Actions from RunJS query

Actions are normally configured through an event handler in the App Builder, but you can also trigger them programmatically from a RunJS query using the actions.* API. This is useful when the logic is conditional, needs to run inside a loop, or needs to combine several actions together — see Custom Code: Control Components for more on when to reach for RunJS.

This page is a quick-reference of every action's RunJS syntax, grouped the same way as the Actions Reference. Each entry links to the action's own page for full parameter details, behavior notes, and examples.

Run Action

ActionRunJS syntax
Run Queryqueries.<queryName>.run() or await actions.runQuery('<queryName>')
Reset Queryqueries.<queryName>.reset() or await actions.resetQuery('<queryName>')
Abort Queryqueries.<queryName>.abort() or await actions.abortQuery('<queryName>')
Show Alertactions.showAlert('<alertType>', '<message>')

Control Component

ActionRunJS syntax
Control Componentawait components.<componentName>.<csaMethod>(<params>) — invoked directly on the component, not through actions.*
Show Modalactions.showModal('<modalName>')
Close Modalactions.closeModal('<modalName>')
Set Table PageNot available via actions.* — use await components.<tableName>.setPage(<pageIndex>)
Scroll Component into Viewactions.scrollComponentInToView('<componentName>')
ActionRunJS syntax
Switch Pageawait actions.switchPage('<pageHandle>') (optionally with query params — see the action's page)
Go to Appactions.goToApp('<slug>', queryParams)
Open Web PageNot available via actions.* — use window.open('<url>', '_blank')

Variable

ActionRunJS syntax
Set Page Variableawait actions.setPageVariable('<key>', <value>)
Unset Page Variableawait actions.unsetPageVariable('<key>')
Unset All Page Variableactions.unsetAllPageVariables()
Set Variableactions.setVariable('<key>', <value>)
Unset Variableactions.unSetVariable('<key>')
Unset All Variableactions.unsetAllVariables()

Other

ActionRunJS syntax
Logoutactions.logout()
Generate Fileactions.generateFile('<fileName>', '<fileType>', '<data>')
Set Local Storageactions.setLocalStorage('<key>', '<value>')
Copy to Clipboardactions.copyToClipboard('<contentToCopy>')
Toggle App Modeactions.toggleAppMode('<light|dark>')

Reading query and variable data

These aren't actions — they're getters for immediately reading state right after triggering a query or setting a variable in the same RunJS query.

Query data

await queries.getSalesData.run();
let value = queries.getSalesData.getData(); // resolved data
let raw = queries.getSalesData.getRawData(); // raw response
let loading = queries.getSalesData.getloadingState();

The response returned by actions.runQuery() / queries.queryName.run() is an object containing both status and data, so you can also read it inline:

const response = await actions.runQuery('getOrders', { limit: 10 });
return response;
// { status: "ok", data: [ { id: 1, customer_name: "John Doe", total: 250 } ] }

Variables

actions.setVariable('mode', 'dark');
return actions.getVariable('mode');
actions.setPageVariable('number', 1);
return actions.getPageVariable('number');

Running multiple actions from a RunJS query

Use async/await to sequence several actions together. The example below runs two queries and shows an alert at a fixed interval — see the full guide on running queries at specified intervals.

actions.setVariable('interval', setInterval(countdown, 5000));
async function countdown() {
await queries.restapi1.run();
await queries.restapi2.run();
await actions.showAlert('info', 'This is an information');
}