<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Setting token programatically when token has selectFirstChoice=true in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Setting-token-programatically-when-token-has-selectFirstChoice/m-p/474092#M31119</link>
    <description>&lt;P&gt;Setting tokens in Splunk programatically in Splunk via JS is pretty easy, as documented at:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://dev.splunk.com/enterprise/docs/developapps/webframework/binddatausingtokens/getandsettokenvalues/" target="_blank"&gt;https://dev.splunk.com/enterprise/docs/developapps/webframework/binddatausingtokens/getandsettokenvalues/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;However, the code snippet at that link appears to have no effect on tokens with true&lt;/P&gt;
&lt;P&gt;I have developed the following workaround...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;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);
});
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Evidently however, this is a hack, as it reaches into the _events attribute which is marked as not a public API.&lt;BR /&gt;Thus, I would like a more elegant solution. Any ideas?&lt;/P&gt;
&lt;P&gt;Cheers &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 08 Jun 2020 00:13:06 GMT</pubDate>
    <dc:creator>delewis13</dc:creator>
    <dc:date>2020-06-08T00:13:06Z</dc:date>
    <item>
      <title>Setting token programatically when token has selectFirstChoice=true</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Setting-token-programatically-when-token-has-selectFirstChoice/m-p/474092#M31119</link>
      <description>&lt;P&gt;Setting tokens in Splunk programatically in Splunk via JS is pretty easy, as documented at:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://dev.splunk.com/enterprise/docs/developapps/webframework/binddatausingtokens/getandsettokenvalues/" target="_blank"&gt;https://dev.splunk.com/enterprise/docs/developapps/webframework/binddatausingtokens/getandsettokenvalues/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;However, the code snippet at that link appears to have no effect on tokens with true&lt;/P&gt;
&lt;P&gt;I have developed the following workaround...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;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);
});
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Evidently however, this is a hack, as it reaches into the _events attribute which is marked as not a public API.&lt;BR /&gt;Thus, I would like a more elegant solution. Any ideas?&lt;/P&gt;
&lt;P&gt;Cheers &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 00:13:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Setting-token-programatically-when-token-has-selectFirstChoice/m-p/474092#M31119</guid>
      <dc:creator>delewis13</dc:creator>
      <dc:date>2020-06-08T00:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: Setting token programatically when token has selectFirstChoice=true</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Setting-token-programatically-when-token-has-selectFirstChoice/m-p/474093#M31120</link>
      <description>&lt;P&gt;@delewis13  not a direct answer to the question, though have a look at this app: Splunk Dev For All&lt;BR /&gt;
&lt;A href="https://splunkbase.splunk.com/app/4104/"&gt;https://splunkbase.splunk.com/app/4104/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;It has a good walkthrough no how to use JS with Splunk to do this sort of task.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2020 05:17:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Setting-token-programatically-when-token-has-selectFirstChoice/m-p/474093#M31120</guid>
      <dc:creator>anmolpatel</dc:creator>
      <dc:date>2020-04-09T05:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: Setting token programatically when token has selectFirstChoice=true</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Setting-token-programatically-when-token-has-selectFirstChoice/m-p/474094#M31121</link>
      <description>&lt;P&gt;@delewis13 could you please paste your corresponding dashboard code?&lt;/P&gt;</description>
      <pubDate>Thu, 14 May 2020 14:57:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Setting-token-programatically-when-token-has-selectFirstChoice/m-p/474094#M31121</guid>
      <dc:creator>rvany</dc:creator>
      <dc:date>2020-05-14T14:57:33Z</dc:date>
    </item>
  </channel>
</rss>

