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.

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...