<?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 Splunk Enterprise fill tokens with JavaScript in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-Enterprise-fill-tokens-with-JavaScript/m-p/566127#M46518</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I have created a Splunk form which has some html form inputs to update a lookup for me. To get the values from the html form inputs I'm using a Javascript code, such as the one bellow:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;require(["splunkjs/mvc",
"jquery",
"splunkjs/ready!",
"splunkjs/mvc/simplexml/ready!"
], function( mvc,
$){
var tokens = mvc.Components.get("default");

$('#addentry').on("click", function (e){

var field1 = $("input[name=field1]").val();
tokens.set("tok_add_field1", field1);

})
});&lt;/LI-CODE&gt;&lt;P&gt;Once &lt;U&gt;&lt;EM&gt;addentry&lt;/EM&gt;&lt;/U&gt; button is clicked the token is filled by the Javascript and a base search should run to update the value in a lookup. Problem is, after the token which the search needs is filled it still doesn't run (It runs if I go to Edit -&amp;gt; Source -&amp;gt; Cancel).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Search:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;search id="add_results"&amp;gt;
&amp;lt;query&amp;gt;
| inputlookup example.csv
| append [ makeresults | eval field1="$tok_add_field1$"]
| outputlookup example.csv
&amp;lt;/query&amp;gt;
&amp;lt;finalized&amp;gt;
&amp;lt;set token="confirmation"&amp;gt;Search executed!&amp;lt;/set&amp;gt;
&amp;lt;/finalized&amp;gt;
&amp;lt;/search&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;Could someone please tell me what is missing in my search so that it is automatically executed once the tokens are filled?&amp;nbsp; Thanks a lot!&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Additionally:&lt;/STRONG&gt; I have noticed that once a Splunk input is filled, adding "?" to the URL, javascript will no longer update the tokens. Maybe a problem with the interaction between JS and browser.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Sep 2021 12:26:14 GMT</pubDate>
    <dc:creator>vini98limasilva</dc:creator>
    <dc:date>2021-09-07T12:26:14Z</dc:date>
    <item>
      <title>Splunk Enterprise fill tokens with JavaScript</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-Enterprise-fill-tokens-with-JavaScript/m-p/566127#M46518</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I have created a Splunk form which has some html form inputs to update a lookup for me. To get the values from the html form inputs I'm using a Javascript code, such as the one bellow:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;require(["splunkjs/mvc",
"jquery",
"splunkjs/ready!",
"splunkjs/mvc/simplexml/ready!"
], function( mvc,
$){
var tokens = mvc.Components.get("default");

$('#addentry').on("click", function (e){

var field1 = $("input[name=field1]").val();
tokens.set("tok_add_field1", field1);

})
});&lt;/LI-CODE&gt;&lt;P&gt;Once &lt;U&gt;&lt;EM&gt;addentry&lt;/EM&gt;&lt;/U&gt; button is clicked the token is filled by the Javascript and a base search should run to update the value in a lookup. Problem is, after the token which the search needs is filled it still doesn't run (It runs if I go to Edit -&amp;gt; Source -&amp;gt; Cancel).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Search:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;search id="add_results"&amp;gt;
&amp;lt;query&amp;gt;
| inputlookup example.csv
| append [ makeresults | eval field1="$tok_add_field1$"]
| outputlookup example.csv
&amp;lt;/query&amp;gt;
&amp;lt;finalized&amp;gt;
&amp;lt;set token="confirmation"&amp;gt;Search executed!&amp;lt;/set&amp;gt;
&amp;lt;/finalized&amp;gt;
&amp;lt;/search&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;Could someone please tell me what is missing in my search so that it is automatically executed once the tokens are filled?&amp;nbsp; Thanks a lot!&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Additionally:&lt;/STRONG&gt; I have noticed that once a Splunk input is filled, adding "?" to the URL, javascript will no longer update the tokens. Maybe a problem with the interaction between JS and browser.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 12:26:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-Enterprise-fill-tokens-with-JavaScript/m-p/566127#M46518</guid>
      <dc:creator>vini98limasilva</dc:creator>
      <dc:date>2021-09-07T12:26:14Z</dc:date>
    </item>
  </channel>
</rss>

