<?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: Populate dropdown without clicking a first time on the submit button in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Populate-dropdown-without-clicking-a-first-time-on-the-submit/m-p/432802#M42171</link>
    <description>&lt;P&gt;Hey csimonnet,&lt;/P&gt;

&lt;P&gt;Have you tried adding the token from your dropdown to your base search?&lt;BR /&gt;
I made a quick dashboard using makeresults to illustrate the concept:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;testdash&amp;lt;/label&amp;gt;
  &amp;lt;search id="primary"&amp;gt;
    &amp;lt;query&amp;gt;|makeresults count=100
| eval logtype = random()%5
| eval dynamic_field = if(logtype = 0, "dogs", if(logtype = 1, "cats", if(logtype = 2, "lizards", if(logtype = 3, "snakes", if(logtype = 4, "bears", "")))))  
| search $dynamic_dropdown$
&amp;lt;/query&amp;gt;
    &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
    &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
    &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;fieldset submitButton="true" autoRun="true"&amp;gt;
    &amp;lt;input type="dropdown" token="dynamic_dropdown" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;Animal Types&amp;lt;/label&amp;gt;
      &amp;lt;choice value="dynamic_field=*"&amp;gt;all&amp;lt;/choice&amp;gt;
      &amp;lt;default&amp;gt;dynamic_field=*&amp;lt;/default&amp;gt;
      &amp;lt;initialValue&amp;gt;dynamic_field=*&amp;lt;/initialValue&amp;gt;
      &amp;lt;fieldForLabel&amp;gt;dynamic_field&amp;lt;/fieldForLabel&amp;gt;
      &amp;lt;fieldForValue&amp;gt;value&amp;lt;/fieldForValue&amp;gt;
      &amp;lt;search&amp;gt;
        &amp;lt;query&amp;gt;|makeresults count=100
| eval logtype = random()%5
| eval dynamic_field = if(logtype = 0, "dogs", if(logtype = 1, "cats", if(logtype = 2, "lizards", if(logtype = 3, "snakes", if(logtype = 4, "bears", ""))))) 
| dedup dynamic_field 
| sort dynamic_field 
| eval value="dynamic_field=".dynamic_field&amp;lt;/query&amp;gt;
      &amp;lt;/search&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;search base="primary"&amp;gt;
          &amp;lt;query&amp;gt;|stats count&amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
      &amp;lt;/single&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me break it down:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&amp;lt;search id="primary"&amp;gt;&lt;/CODE&gt; defines your base search. This search will populate all of your other panels based on this high level search. &lt;BR /&gt;
Typically this search will look something like:&lt;BR /&gt;
&lt;STRONG&gt;index=your_index sourcetype=your_sourcetype source=your_source | fields field1 field2 field3&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;You call on this search by adding &lt;CODE&gt;&amp;lt;search_base="primary"&amp;gt;&lt;/CODE&gt; to any panel that would would like to build on from the base search.&lt;BR /&gt;
You can see an example of this in the dashboard above:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;search base="primary"&amp;gt;
 &amp;lt;query&amp;gt;|stats count&amp;lt;/query&amp;gt;
&amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Notice how the &lt;CODE&gt;&amp;lt;query&amp;gt;&lt;/CODE&gt; is very small, that's because it's taking the base search as a starting point and adding onto it.&lt;/P&gt;

&lt;P&gt;Lastly, notice in the example dashboard I've added &lt;CODE&gt;|search $dynamic_dropdown$&lt;/CODE&gt; to my base search. This is a reference to the token that dynamically populates the dropdown with the values from my search. Without this, your dropdown won't have any effects on your dashboard.&lt;/P&gt;

&lt;P&gt;The only other thing I can think of to add is the &lt;CODE&gt;searchWhenChanged="true"&lt;/CODE&gt; option. If you would like your dashboard to only populate when the submit button is pushed, change this to &lt;CODE&gt;false&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Hopefully this helps. &lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 00:17:28 GMT</pubDate>
    <dc:creator>rbechtold</dc:creator>
    <dc:date>2020-09-30T00:17:28Z</dc:date>
    <item>
      <title>Populate dropdown without clicking a first time on the submit button</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Populate-dropdown-without-clicking-a-first-time-on-the-submit/m-p/432800#M42169</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;

&lt;P&gt;I have a dashboard with dropdowns with dynamic options and a submit button to run my searches. But my dropdowns are not populated if I don't click on the submit button a first time. How can I change that ? &lt;/P&gt;

&lt;P&gt;Thank you for your answers&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 14:48:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Populate-dropdown-without-clicking-a-first-time-on-the-submit/m-p/432800#M42169</guid>
      <dc:creator>csimonnet</dc:creator>
      <dc:date>2019-04-26T14:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Populate dropdown without clicking a first time on the submit button</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Populate-dropdown-without-clicking-a-first-time-on-the-submit/m-p/432801#M42170</link>
      <description>&lt;P&gt;Can you post the &lt;CODE&gt;&amp;lt;fieldset&lt;/CODE&gt; section of your dashboard? Do remember to format the code using "101010" button on top of the text editor here OR select the code and press Ctrl+K.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 16:20:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Populate-dropdown-without-clicking-a-first-time-on-the-submit/m-p/432801#M42170</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2019-04-26T16:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: Populate dropdown without clicking a first time on the submit button</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Populate-dropdown-without-clicking-a-first-time-on-the-submit/m-p/432802#M42171</link>
      <description>&lt;P&gt;Hey csimonnet,&lt;/P&gt;

&lt;P&gt;Have you tried adding the token from your dropdown to your base search?&lt;BR /&gt;
I made a quick dashboard using makeresults to illustrate the concept:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;testdash&amp;lt;/label&amp;gt;
  &amp;lt;search id="primary"&amp;gt;
    &amp;lt;query&amp;gt;|makeresults count=100
| eval logtype = random()%5
| eval dynamic_field = if(logtype = 0, "dogs", if(logtype = 1, "cats", if(logtype = 2, "lizards", if(logtype = 3, "snakes", if(logtype = 4, "bears", "")))))  
| search $dynamic_dropdown$
&amp;lt;/query&amp;gt;
    &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
    &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
    &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;fieldset submitButton="true" autoRun="true"&amp;gt;
    &amp;lt;input type="dropdown" token="dynamic_dropdown" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;Animal Types&amp;lt;/label&amp;gt;
      &amp;lt;choice value="dynamic_field=*"&amp;gt;all&amp;lt;/choice&amp;gt;
      &amp;lt;default&amp;gt;dynamic_field=*&amp;lt;/default&amp;gt;
      &amp;lt;initialValue&amp;gt;dynamic_field=*&amp;lt;/initialValue&amp;gt;
      &amp;lt;fieldForLabel&amp;gt;dynamic_field&amp;lt;/fieldForLabel&amp;gt;
      &amp;lt;fieldForValue&amp;gt;value&amp;lt;/fieldForValue&amp;gt;
      &amp;lt;search&amp;gt;
        &amp;lt;query&amp;gt;|makeresults count=100
| eval logtype = random()%5
| eval dynamic_field = if(logtype = 0, "dogs", if(logtype = 1, "cats", if(logtype = 2, "lizards", if(logtype = 3, "snakes", if(logtype = 4, "bears", ""))))) 
| dedup dynamic_field 
| sort dynamic_field 
| eval value="dynamic_field=".dynamic_field&amp;lt;/query&amp;gt;
      &amp;lt;/search&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;search base="primary"&amp;gt;
          &amp;lt;query&amp;gt;|stats count&amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
      &amp;lt;/single&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me break it down:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&amp;lt;search id="primary"&amp;gt;&lt;/CODE&gt; defines your base search. This search will populate all of your other panels based on this high level search. &lt;BR /&gt;
Typically this search will look something like:&lt;BR /&gt;
&lt;STRONG&gt;index=your_index sourcetype=your_sourcetype source=your_source | fields field1 field2 field3&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;You call on this search by adding &lt;CODE&gt;&amp;lt;search_base="primary"&amp;gt;&lt;/CODE&gt; to any panel that would would like to build on from the base search.&lt;BR /&gt;
You can see an example of this in the dashboard above:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;search base="primary"&amp;gt;
 &amp;lt;query&amp;gt;|stats count&amp;lt;/query&amp;gt;
&amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Notice how the &lt;CODE&gt;&amp;lt;query&amp;gt;&lt;/CODE&gt; is very small, that's because it's taking the base search as a starting point and adding onto it.&lt;/P&gt;

&lt;P&gt;Lastly, notice in the example dashboard I've added &lt;CODE&gt;|search $dynamic_dropdown$&lt;/CODE&gt; to my base search. This is a reference to the token that dynamically populates the dropdown with the values from my search. Without this, your dropdown won't have any effects on your dashboard.&lt;/P&gt;

&lt;P&gt;The only other thing I can think of to add is the &lt;CODE&gt;searchWhenChanged="true"&lt;/CODE&gt; option. If you would like your dashboard to only populate when the submit button is pushed, change this to &lt;CODE&gt;false&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Hopefully this helps. &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:17:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Populate-dropdown-without-clicking-a-first-time-on-the-submit/m-p/432802#M42171</guid>
      <dc:creator>rbechtold</dc:creator>
      <dc:date>2020-09-30T00:17:28Z</dc:date>
    </item>
  </channel>
</rss>

