Setting tokens in Splunk programatically in Splunk via JS is pretty easy, as documented at:
https://dev.splunk.com/enterprise/docs/developapps/webframework/binddatausingtokens/getandsettokenvalues/
However, the code snippet at that link appears to have no effect on tokens with true
I have developed the following workaround...
require([
"underscore",
"jquery",
"splunkjs/mvc",
"splunkjs/mvc/simplexml/ready!"
], function (_, $, mvc) {
var tokens = mvc.Components.get("default");
var tokenName = "myTokenName";
var tokenValue = "myTokenValue";
tokens._events[`change:${myTokenName}`][0].context.attributes.selectFirstChoice = false
tokens.set(myTokenName, myTokenValue);
});
Evidently however, this is a hack, as it reaches into the _events attribute which is marked as not a public API. Thus, I would like a more elegant solution. Any ideas?
Cheers 🙂
... View more