<?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 Re: Set token in Javascript doesnt trigger update in Simple XML in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Set-token-in-Javascript-doesnt-trigger-update-in-Simple-XML/m-p/132774#M36261</link>
    <description>&lt;P&gt;I had the same issue - manually starting the search inside the event listener worked brilliantly for me. &lt;/P&gt;</description>
    <pubDate>Sun, 21 Aug 2016 23:00:36 GMT</pubDate>
    <dc:creator>svenwendler</dc:creator>
    <dc:date>2016-08-21T23:00:36Z</dc:date>
    <item>
      <title>Set token in Javascript doesnt trigger update in Simple XML</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-token-in-Javascript-doesnt-trigger-update-in-Simple-XML/m-p/132770#M36257</link>
      <description>&lt;P&gt;I am trying to update a table when an item in my javascript chart is clicked. Previously, this worked fine:&lt;BR /&gt;
JavaScript:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;function drilldown(appName){
                tokens.set("vsadid", appName);
                console.log(appName);               mvc.Components.getInstance("drilldownSearch").startSearch();            
            }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Splunk HTML:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;div id="drilldownSearch" class="splunk-manager" data-require="splunkjs/mvc/searchmanager" data-options="{    &amp;amp;quot;search&amp;amp;quot;: { &amp;amp;quot;type&amp;amp;quot;: &amp;amp;quot;token_safe&amp;amp;quot;, &amp;amp;quot;value&amp;amp;quot;: &amp;amp;quot;|inputlookup combinedrisk.csv | search VSADID=$$vsadid$$ | table VSADID RiskScore FootPrintFactor RiskTag Tier5 Tier4&amp;amp;quot; }, &amp;amp;quot;cache&amp;amp;quot;: false,    &amp;amp;quot;preview&amp;amp;quot;: false    }"&amp;gt;
        &amp;lt;/div&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But my search string became so complex with single and double quotes and &amp;lt; and &amp;gt; that I wanted to switch to XML to use the CDATA tag. So now my code is:&lt;/P&gt;

&lt;P&gt;JavaScript: Same&lt;BR /&gt;
Splunk XML:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;panel depends="$vsadid$"&amp;gt;
      &amp;lt;title&amp;gt;Data View&amp;lt;/title&amp;gt;
      &amp;lt;table id="drilldownTable"&amp;gt;
      &amp;lt;search id="drilldownSearch"&amp;gt;
        &amp;lt;query&amp;gt;&amp;lt;![CDATA[|search VSADID=$vsadid$]] truncated for clarity&amp;gt;&amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Except the problem is that this search does not start unless I change one of the other input drop-downs I have in the dashboard, which cause the searches to run on change. And when the token changes, the table won't change unless I do the same thing. Why is this?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2015 21:14:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-token-in-Javascript-doesnt-trigger-update-in-Simple-XML/m-p/132770#M36257</guid>
      <dc:creator>rmearkle</dc:creator>
      <dc:date>2015-07-22T21:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: Set token in Javascript doesnt trigger update in Simple XML</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-token-in-Javascript-doesnt-trigger-update-in-Simple-XML/m-p/132771#M36258</link>
      <description>&lt;P&gt;Ok, I think I see what you want.  You want to use &lt;STRONG&gt;on&lt;/STRONG&gt; event handler and bind it to the id of your drop down.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  // yourDropDown is the id of them drop down menu
  var tokens = mvc.Components.getInstance("default");
  var yourDropDown = mvc.Components.getInstance("yourDropDown")
  var drillDownSearch = mvc.Components.getInstance("drilldownSearch")

  // Using an event handler to listen for changes to the drop down.
  yourDropDown.on('change', function() {
    tokens.set("vsadid", appName);
    drillDownSearch.startSearch()
  })
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;take a peak at the following documentation. &lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/WebFramework"&gt;WebFrame Work Reference&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://dev.splunk.com/view/SP-CAAAES4"&gt;Tokens&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2015 17:54:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-token-in-Javascript-doesnt-trigger-update-in-Simple-XML/m-p/132771#M36258</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2015-07-23T17:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: Set token in Javascript doesnt trigger update in Simple XML</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-token-in-Javascript-doesnt-trigger-update-in-Simple-XML/m-p/132772#M36259</link>
      <description>&lt;P&gt;Unfortunately no, what I was trying to explain is that the token is set by an onClick event in javascript by a custom D3 chart, it just doesn't trigger the table to refresh. When I make a change to a dropdown on the page (not linked to that token) since it has the searchWhenChanged parameter linked, that other dropdown triggers the refresh.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2015 18:49:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-token-in-Javascript-doesnt-trigger-update-in-Simple-XML/m-p/132772#M36259</guid>
      <dc:creator>rmearkle</dc:creator>
      <dc:date>2015-07-24T18:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: Set token in Javascript doesnt trigger update in Simple XML</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-token-in-Javascript-doesnt-trigger-update-in-Simple-XML/m-p/132773#M36260</link>
      <description>&lt;P&gt;I solved this issue by switching to a base search for all the calculations of lookups and evals, and just used a simple postprocess search created in my javascript code.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var dataSearch = new PostProcessManager({
                    "id": "dataSearch",
                    "managerid": "baseCalcSearch",
                    "search": "|search VSADID=$vsadid$ |table \"VSADID\""
                }, {tokens: true});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I was using XML just because of my long search string in a CDATA tag, but keeping the base search in CDATA XML and using these PostProcessManagers worked for me.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2015 18:51:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-token-in-Javascript-doesnt-trigger-update-in-Simple-XML/m-p/132773#M36260</guid>
      <dc:creator>rmearkle</dc:creator>
      <dc:date>2015-07-24T18:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: Set token in Javascript doesnt trigger update in Simple XML</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-token-in-Javascript-doesnt-trigger-update-in-Simple-XML/m-p/132774#M36261</link>
      <description>&lt;P&gt;I had the same issue - manually starting the search inside the event listener worked brilliantly for me. &lt;/P&gt;</description>
      <pubDate>Sun, 21 Aug 2016 23:00:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-token-in-Javascript-doesnt-trigger-update-in-Simple-XML/m-p/132774#M36261</guid>
      <dc:creator>svenwendler</dc:creator>
      <dc:date>2016-08-21T23:00:36Z</dc:date>
    </item>
  </channel>
</rss>

