Dashboards & Visualizations

How to pass a token value from dashboard Simple XML to a JavaScript file?

kabiraj
Path Finder

I want to pass a token value from a dashboard Simple XML page to the js file which is attached with the XML.
e.g.

<form script="abc.js">
    <input type="text" token="def" searchWhenChanged="true">
      <label>DEF</label>
    </input>
.
.
.
.
</form>

I want to pass the value of "def" to "abc.js". Is it possible to do?

0 Karma

jeffland
SplunkTrust
SplunkTrust

In your .js, you need to require the right stuff, and then you can simply grab the tokens from the token model. Something like this:

require([
    'splunkjs/mvc/simplexml/ready!',
    "splunkjs/mvc"
],
function(
    mvc
    ) {
        // Get the default model
        var defaultTokenModel = splunkjs.mvc.Components.getInstance("default");
        // Get some token from there
        var token_def = defaultTokenModel.get("def");
        ...

See here for the docs.

Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...