Below is a sample of JavaScript I use to set a token:
require([
"splunkjs/mvc",
"splunkjs/mvc/simplexml/ready!"
], function(mvc) {
var tokens = mvc.Components.get("default");
tokens.set("check_status", "true");
});
Presumably your JavaScript would have some code to check whether or not to set the token. Also, depending on your logic, you may want to unset the token as well like this:
tokens.unset("check_status");
Not sure how familiar you are with using JavaScript in Splunk, but your JavaScript file would go here (create the folders if they don't already exist):
$SPLUNK_HOME\etc\apps\<yourapp>\appserver\static
and you would reference it in your XML like this, by adding a script attribute to your form or dashboard tag:
<form script="yourjavascript.js">
... View more