Run Actions from RunJS query
ToolJet allows you to execute various actions within RunJS queries. This guide outlines the syntax and examples for each action.
Run Query
To trigger a query, you can use the below functions:
queries.getSalesData.run();
// replace getSalesData with your query name
or
await actions.runQuery("getSalesData");
// replace getSalesData with your query name
Example:
In the screenshot below, we are triggering two different queries using two different syntax available for Run Query action.

Get Query Data
In the previous section, we saw how we can trigger queries. Once the queries are triggered, if you want to immediately use the data returned by the query inside the RunJS query, you can use the getData(), getRawData() and getLoadingState() functions:
Trigger a query and retrieve its data:
await queries.getSalesData.run();
// replace getSalesData with your query name
let value = queries.getSalesData.getData();
// replace getSalesData with your query name
Trigger a query and retrieve its raw data:
await queries.getCustomerData.run();
//replace getCustomerData with your query name
let value = queries.getCustomerData.getRawData();
// replace getCustomerData your with query name
Trigger a query and retrieve its loading state:
await queries.getTodos.run();
//replace getTodos with your query name
let value = queries.getTodos.getLoadingState();
//replace getTodos with your query name
Set Variables
To create a variable, you can use the below function:
actions.setVariable("<variableName>", `<variableValue>`);
Unset Variable
To delete a created variable, you can use the below function:
Syntax:
actions.unSetVariable("<variableName>");
Get Variables
To access variables immediately after setting them in a RunJS query, you can use the getVariable and getPageVariable functions:
Set and retrieve a variable:
actions.setVariable("mode", "dark");
//replace mode with your desired variable name
return actions.getVariable("mode");
Set and retrieve a page-specific variable:
actions.setPageVariable("number", 1);
//replace number with your desired variable name
return actions.getPageVariable("number");
Logout
To log out the current logged-in user from the ToolJet, use the below function:
actions.logout();