Include DataCube.lastModifiedTime in Dashboard

I need to add the data cube property for last modified time to a dashboard so the client can see the freshness of the data. I found a little scripting in an older post, but it’s over my head. Is there and “Easy” button I can press? Or someone who can walk me through the process like the newbie I am?

Hi Kelly

Here’s a commented script that you can implement.

All you need to do is change the cube ID and label script name (not the friendly name) in the first two lines, and paste this script in the ‘on ready’ interaction of the dashboard so it updates when the dashboard loads. You could also put in on the ‘on click’ interaction of a button.

Let me know how you get on.

//put in the cubeID that you want to look at - enclose it in double quotes
var cubeID = "28df9970-d859-46ec-bccb-9de5b027120b";   

//put in the script name of the label on the dashboard that you want the info to display in
var label = LBLlastUpdated;

//how you want the date formatted. Could leave it or change as desired.
//This will give Tuesday, March 23, 2021
// You can also change the culture in the last line of the script - it's US currently
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };

// now we do the stuff

//get the cube service
var cubeService = dundas.context.getService("DataCubeService");

//get the last modified time for cube
cubeService.getDataCubeById(cubeID).done(function (theCube)
{
	var lastModifiedTime = theCube.lastModifiedTime;

        //This will show 'Last updated: and then a new line (\n) plus the date on the second line
	label.labelText = "Last updated:\n" + lastModifiedTime.toLocaleDateString("en-US", options);
}
)
4 Likes

Thank you David, this worked beautifully!

1 Like

Always happy to help @kelly :grinning: