Showing results for 
Search instead for 
Did you mean: 
Community Team Member
Community Team Member
Using the code from this article, a user can detect whether or not an ElastiCube is currently building, and refresh if the ElastiCube is not building. More importantly, the code in this article can be used as a framework for utilizing REST API functions in a dashboard’s custom javascript code.
The code used for this example is attached- refresh_check.js
REST API - /elasticubes/servers/{server}/status
The REST API command /elasticubes/servers/{server}/status gets the current status of every Elasticube on a provided server. For this example, we will input the server name, as well as the name of the ElastiCube we want to check (In this scenario it’s NORTHWND).  
In the response body, you can see the actual status value for an ElastiCube. In this case, 1 means stopped, 2 means running, and everything else means error or building. We would like to only refresh the dashboard when the value is either 1 or 2.
To determine the status of the ElastiCube, we will use the Request URL. Simply append the address provided to the end of the url used to access SiSense. In my case, the full url is: http://localhost:8081/api/elasticubes/servers/LocalHost/status?q=NORTHWND
This URL can be used in a web browser, and you can check an ElastiCube’s status from there.
Custom Javascript for the Dashboard
The javascript code in refresh_check.js consists of 3 main sections:
1. Variable declarations
2. Ajax command that gets the status
3. Conditional statement to refresh

Variable Declarations

You’ll need to modify two different variables to use this code on your own.
var url = "http://localhost:8081/api/elasticubes/servers/LocalHost/status?q=NORTHWND";
Simply put in the url you generated in the REST API section into the quotes
var timeoutLength = 5000;
This variables specifies how often to refresh the dashboard, in milliseconds. It currently tries to refresh every 5 seconds.

Ajax Command

You shouldn’t need to make any modifications to this part of the code. In general terms, it reads the json generated by the url specified, and parses the status code to determine what the value means. The status code is parsed in the switch function.

Conditional Statement

This part of the code simply checks to see if the status retrieved in the ajax command is not ‘Building’. It executes the refresh() command if it isn’t building.
To implement this code, open the dashboard you would like to implement this functionality on, and edit the script for that dashboard
Put your modified version of the refresh_check.js code into this editor, click save , and you're finished.

Related Links

Dashboard auto refresh guide:
In order to make the dashboard auto refresh every x seconds, we can use the following script:
In the Dashboard Script:
Set the widget to refresh every 10 seconds by setting refreshIntervalMiliSec to 10000.
dashboard.on('initialized', function(dashboard, ev){
    var refreshIntervalMiliSec = 10000;
    var refreshDashboard = function(){
  setTimeout(refreshDashboard, refreshIntervalMiliSec);
    setTimeout(refreshDashboard, refreshIntervalMiliSec);
Welcome to your Dashboard's Script. 

 - You can access your Dashboard by accessing the 'dashboard' variable name.
 - You can access your Dashboard's DOM via the 'element' variable name (undefined until DOM creation).

 - For a complete API reference for Widgets and Dashboards go here:

dashboard.on('initialized', function(s,e) {
 // Build Query URL
 var url = "http://localhost:8081/api/elasticubes/servers/LocalHost/status?q=NORTHWND";
 // Define timeout length in milliseconds
 var timeoutLength = 5000;
 var curStatus = '';
 setInterval( function() {
  // Run query using jaql
  $.ajax( {
   url: url,
   type: "GET",
   dataType: "json",
   async: true,
   success: function(data, textStatus) {
    // Get the Result Set
    var statusCode = data[0].status;
    var status = '';
    switch(statusCode) {
     case 1: status = 'Stopped'; 
     case 2: status = 'Running'; 
     default: status = 'Building'; 
    //var curStatus=status;
    if (status != 'Building'){

  }); //end of ajax command 
 }, timeoutLength);
Version history
Last update:
‎03-02-2023 09:22 AM
Updated by:
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Developers Group:

Product Feedback Forum:

Need additional support?:

Submit a Support Request

The Legal Stuff

Have a question about the Sisense Community?

Email [email protected]

Share this page: