cancel
Showing results for 
Search instead for 
Did you mean: 

Show Last Updated Date on Dashboard

amelia
10 - ETL
10 - ETL

Hi! I'm creating a dashboard and want to show when the data source for the dashboard was last refreshed at the top of the dashboard, since the users will want this. Is there any widget I can add or script to add to achieve this? 

1 ACCEPTED SOLUTION

harikm007
13 - Data Warehouse
13 - Data Warehouse

@amelia 

Create a text box and add below script to it. (Update elasticube name in the script.)

harikm007_0-1656614245359.png

 

function runHTTP() {
	
	datasource = [
					{
						"elasticube": "elasticube name",
						"server": "localhost"
					}
				]
  // Use $internalHttp service if exists
  const $internalHttp = prism.$injector.has("base.factories.internalHttp") ?
  prism.$injector.get("base.factories.internalHttp") : null;
  // Ajax configurations
  const ajaxConfig = {
    url: "/api/v1/elasticubes/getElasticubes",
    method: "POST",
    data: JSON.stringify(datasource),
    contentType: "application/json",
    dataType: "json",
    async: false
  };
  // Use $internalHttp service for v8.0.1+
  // else use default ajax request
  const httpPromise = $internalHttp ? $internalHttp(ajaxConfig, true) : $.ajax(ajaxConfig);

  // Return response
  return httpPromise.responseJSON;
};


widget.on('domready', function(se, ev) {
  elasticubedetails = runHTTP();
  ev.widget.style.content.html = '<font size=\"5\">' + moment(elasticubedetails[0].lastBuildTime).format('MMMM Do YYYY, h:mm:ss a') + '</font>' //change this to update style and text
})

Thanks @Ophir_Buchman for the post 'how to run HTTP request from sisense'

-Hari

 

View solution in original post

12 REPLIES 12

harikm007
13 - Data Warehouse
13 - Data Warehouse

Hi @amelia ,

We can see 'Last Built' date and time at the top of dashboard. Are you for a widget instead of this?

harikm007_0-1656612267280.png

-Hari

 

Yes, if possible I want to have a widget that shows this! Or a text box. I want the user to see the last time the data for the dashboard was updated.

harikm007
13 - Data Warehouse
13 - Data Warehouse

@amelia 

Create a text box and add below script to it. (Update elasticube name in the script.)

harikm007_0-1656614245359.png

 

function runHTTP() {
	
	datasource = [
					{
						"elasticube": "elasticube name",
						"server": "localhost"
					}
				]
  // Use $internalHttp service if exists
  const $internalHttp = prism.$injector.has("base.factories.internalHttp") ?
  prism.$injector.get("base.factories.internalHttp") : null;
  // Ajax configurations
  const ajaxConfig = {
    url: "/api/v1/elasticubes/getElasticubes",
    method: "POST",
    data: JSON.stringify(datasource),
    contentType: "application/json",
    dataType: "json",
    async: false
  };
  // Use $internalHttp service for v8.0.1+
  // else use default ajax request
  const httpPromise = $internalHttp ? $internalHttp(ajaxConfig, true) : $.ajax(ajaxConfig);

  // Return response
  return httpPromise.responseJSON;
};


widget.on('domready', function(se, ev) {
  elasticubedetails = runHTTP();
  ev.widget.style.content.html = '<font size=\"5\">' + moment(elasticubedetails[0].lastBuildTime).format('MMMM Do YYYY, h:mm:ss a') + '</font>' //change this to update style and text
})

Thanks @Ophir_Buchman for the post 'how to run HTTP request from sisense'

-Hari

 

Thanks so much, this is really helpful!

R1
7 - Data Storage
7 - Data Storage

Hi Hari,

I understand the above solution if for last build time of an elasticube. Is there a way to get the last build time for a live data model? If yes, please do let me know.

R

This is awesome. Thank you!

Hi @harikm007  I am using the same code for my text box and I am not getting any answer. Can you please help me debug and see what the reason for failure could be?

Here is my code file attached with changed elasticube name.

------------

function runHTTP() {

    datasource = [
                    {
                        "elasticube": "ECSS_BUGTRENDNEW",
                        "server": "localhost"
                    }
                ]
  // Use $internalHttp service if exists
  const $internalHttp = prism.$injector.has("base.factories.internalHttp") ?
  prism.$injector.get("base.factories.internalHttp") : null;
  // Ajax configurations
  const ajaxConfig = {
    url: "/api/v1/elasticubes/getElasticubes",
    method: "POST",
    data: JSON.stringify(datasource),
    contentType: "application/json",
    dataType: "json",
    async: false
  };    
  // Use $internalHttp service for v8.0.1+
  // else use default ajax request
  const httpPromise = $internalHttp ? $internalHttp(ajaxConfig, true) : $.ajax(ajaxConfig);

  // Return response
  return httpPromise.responseJSON;
};


widget.on('domready', function(se, ev) {
  elasticubedetails = runHTTP();
  ev.widget.style.content.html = '<font size=\"5\">' + moment(elasticubedetails[0].lastBuildTime).format('MMMM Do YYYY, h:mm:ss a') + '</font>'
})
---------------------------------------

harikm007
13 - Data Warehouse
13 - Data Warehouse

Hi @bhavyashah ,

I tried the above script and its working for me.

Just to confirm, you added this script to the text widget, not dashboard, right?

Are you getting any error message in browser console?

harikm007_0-1673190544148.png

-Hari

 

Yes I have added the script to text widget and I am not getting any error messages also.twxtbox.PNG

 

bhavyashah
8 - Cloud Apps
8 - Cloud Apps

Hello  reached out the people at sisense customer service and they helped me to find the issue. It is an issue with my version of sisense which hasn't been updated in a while.

Miasm1
8 - Cloud Apps
8 - Cloud Apps

Hello,

To display the last refresh time on your dashboard, add a timestamp widget or use a simple JavaScript script. Check your dashboard tool's documentation for built-in features. Here's a basic script:

<p id="lastRefresh">Data last refreshed: </p> <script>devops course>function updateRefreshTime() {document.getElementById('lastRefresh').textContent = 'Data last refreshed: ' + new Date().toLocaleString();} window.onload = updateRefreshTime;</script>

Adjust based on your tool's capabilities.

I hope this will help you.

Thanks.