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

5 REPLIES 5

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