Dashboards & Visualizations

Was showing time of last update of dashboard in 6.4 using javascript. Stopped working in 6.5. Need suggestion on how to get working in 6.5.

simpkins1958
Contributor

The following XML/Javascript was working in 6.4 to update the lastupdatedtime id. In 6.5 the javascript is now only being called on initial page load. Anyway to get the javascript code called on every refresh like it was in 6.5? Thanks.

Simple XML:

<form refresh="300" script="pageinit.js,system_summary_widths.js">
  <label>System Summary</label>
  <fieldset submitButton="false">
    <html>
        Last updated: <span id="lastupdatetime"></span>
    </html>

Javascript:

require([
    "splunkjs/mvc",
    "splunkjs/mvc/simplexml/ready!"
], function(mvc) {

    var d = new Date();
    var n = d.toLocaleString();
    document.getElementById("lastupdatetime").innerHTML = n;
});
0 Karma

simpkins1958
Contributor

Change my javascript to update the time when one of the searches on the page finishes.

require([
    "splunkjs/mvc",
    "splunkjs/mvc/simplexml/ready!"
], function(mvc) {

    var mySearch = splunkjs.mvc.Components.getInstance("baseSearch_wifi_bytes");

     mySearch.on('search:done', function(properties) {
        var currentDateTime = new Date();
        var currentDateTimeLocalizedString = currentDateTime.toLocaleString();
        document.getElementById("lastupdatetime").innerHTML = currentDateTimeLocalizedString;
    }); 
});
0 Karma
Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...