<?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: Build a Search String with an Arbitrary Number of Conditions in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Build-a-Search-String-with-an-Arbitrary-Number-of-Conditions/m-p/190272#M19394</link>
    <description>&lt;P&gt;Just want to mention, as an update, this is now trivial with Splunk 6.1 by using the &lt;CODE&gt;multiselect&lt;/CODE&gt; input type.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;input type="multiselect" token="my_animals"&amp;gt;
       &amp;lt;label&amp;gt;Types of animals in my soup&amp;lt;/label&amp;gt;
       &amp;lt;populatingSearch earliest="$earliest$" latest="$latest$" fieldForLabel="animal_name" fieldForValue="genus_species"&amp;gt;
                 index=fauna | stats dc(genus_species) by animal_name | fields animal_name genus_species
       &amp;lt;/populatingSearch&amp;gt;
       &amp;lt;default&amp;gt;monkeys,lions&amp;lt;/default&amp;gt;
       &amp;lt;delimiter&amp;gt;OR&amp;lt;/delimiter&amp;gt;
       &amp;lt;valuePrefix&amp;gt;(my_animal=&amp;lt;/valuePrefix&amp;gt;
       &amp;lt;valueSuffix&amp;gt;)&amp;lt;/valueSuffix&amp;gt;
  &amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now you can use the token &lt;CODE&gt;$my_animals$&lt;/CODE&gt; in a search and it will expanded into &lt;CODE&gt;(my_animal=lions) OR (my_animal=monkeys) OR (my_animal=tigers) OR (my_animal=bears)&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 26 Jun 2014 03:41:34 GMT</pubDate>
    <dc:creator>neiljpeterson</dc:creator>
    <dc:date>2014-06-26T03:41:34Z</dc:date>
    <item>
      <title>Build a Search String with an Arbitrary Number of Conditions</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Build-a-Search-String-with-an-Arbitrary-Number-of-Conditions/m-p/190268#M19390</link>
      <description>&lt;P&gt;I want to build a search string with an arbitrary number of OR conditions testing the value of a single variable.&lt;BR /&gt;
The number of OR conditions will be determined by the number of checked checkboxes on a form.&lt;/P&gt;

&lt;P&gt;For example: &lt;BR /&gt;
Given 3 checked checkboxes: RED, WHITE, BLUE, the search string will be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;color=RED OR color=WHITE OR color=BLUE
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If I uncheck RED, the search string will be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;color=WHITE or color=BLUE
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can this be achieved with a simple XML dashboard or do I need to go beyond that (e.g. use JavaScript)?&lt;/P&gt;

&lt;P&gt;To clarify, the number of checkboxes is not known beforehand -- the checkboxes are created dynamically based on a search result.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Dec 2013 08:44:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Build-a-Search-String-with-an-Arbitrary-Number-of-Conditions/m-p/190268#M19390</guid>
      <dc:creator>kwailo</dc:creator>
      <dc:date>2013-12-26T08:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Build a Search String with an Arbitrary Number of Conditions</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Build-a-Search-String-with-an-Arbitrary-Number-of-Conditions/m-p/190269#M19391</link>
      <description>&lt;P&gt;How is this different from your previous question?&lt;/P&gt;

&lt;P&gt;&lt;A href="http://answers.splunk.com/answers/116164/dynamically-appending-or-clauses-based-on-form-input"&gt;http://answers.splunk.com/answers/116164/dynamically-appending-or-clauses-based-on-form-input&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Dec 2013 09:03:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Build-a-Search-String-with-an-Arbitrary-Number-of-Conditions/m-p/190269#M19391</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-12-27T09:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: Build a Search String with an Arbitrary Number of Conditions</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Build-a-Search-String-with-an-Arbitrary-Number-of-Conditions/m-p/190270#M19392</link>
      <description>&lt;P&gt;It has nothing to do with my previous question. I am not asking how the condition should be phrased -- I am asking whether I can generate the condition dynamically with a simple XML dashboard, or whether I have to use JavaScript.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Dec 2013 12:33:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Build-a-Search-String-with-an-Arbitrary-Number-of-Conditions/m-p/190270#M19392</guid>
      <dc:creator>kwailo</dc:creator>
      <dc:date>2013-12-27T12:33:11Z</dc:date>
    </item>
    <item>
      <title>Re: Build a Search String with an Arbitrary Number of Conditions</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Build-a-Search-String-with-an-Arbitrary-Number-of-Conditions/m-p/190271#M19393</link>
      <description>&lt;P&gt;Ah, I see. I know this can be done with AdvancedXML (e.g. Sideview Utils Checkboxes module), and you can do anything with the Splunk JS/Django stack.&lt;/P&gt;

&lt;P&gt;I don't think you can use SimpleXML for this level of flexibility, but I might of course be wrong there. Here's how this would look like in AdvancedXML:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;view isSticky="False" isVisible="true" onunloadCancelJobs="true" template="dashboard.html"&amp;gt;
  &amp;lt;label&amp;gt;Checkboxes&amp;lt;/label&amp;gt;
  &amp;lt;module name="AccountBar" layoutPanel="appHeader" /&amp;gt;
  &amp;lt;module name="AppBar" layoutPanel="appHeader" /&amp;gt;
  &amp;lt;module name="SideviewUtils" layoutPanel="appHeader" /&amp;gt;
  &amp;lt;module name="Message" layoutPanel="messaging"&amp;gt;
    &amp;lt;param name="filter"&amp;gt;*&amp;lt;/param&amp;gt;
    &amp;lt;param name="maxSize"&amp;gt;2&amp;lt;/param&amp;gt;
    &amp;lt;param name="clearOnJobDispatch"&amp;gt;False&amp;lt;/param&amp;gt;
  &amp;lt;/module&amp;gt;

  &amp;lt;module name="HTML" layoutPanel="viewHeader"&amp;gt;
    &amp;lt;param name="html"&amp;gt;&amp;lt;![CDATA[
      &amp;lt;h1&amp;gt;Placeholder Page Title&amp;lt;/h1&amp;gt;
    ]]&amp;gt;&amp;lt;/param&amp;gt;

    &amp;lt;module name="Search" layoutPanel="panel_row1_col1" autoRun="True"&amp;gt;
      &amp;lt;param name="search"&amp;gt;
        | stats count | eval colors = "red,white,blue" | makemv colors delim="," | mvexpand colors | fields - count
      &amp;lt;/param&amp;gt;

      &amp;lt;module name="Checkboxes"&amp;gt;
        &amp;lt;param name="staticCheckboxes"/&amp;gt;
        &amp;lt;param name="name"&amp;gt;color&amp;lt;/param&amp;gt;
        &amp;lt;param name="template"&amp;gt; OR $name$="$value$" &amp;lt;/param&amp;gt;
        &amp;lt;param name="valueField"&amp;gt;colors&amp;lt;/param&amp;gt;

        &amp;lt;module name="Search"&amp;gt;
          &amp;lt;param name="search"&amp;gt;
            | stats count | eval color="red,white,blue" | makemv color delim="," | mvexpand color | streamstats count | search srtophdopgdgohnk $color$
          &amp;lt;/param&amp;gt;

          &amp;lt;module name="Table" /&amp;gt;
        &amp;lt;/module&amp;gt;
      &amp;lt;/module&amp;gt;
    &amp;lt;/module&amp;gt;
  &amp;lt;/module&amp;gt;
&amp;lt;/view&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Dec 2013 13:09:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Build-a-Search-String-with-an-Arbitrary-Number-of-Conditions/m-p/190271#M19393</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-12-27T13:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: Build a Search String with an Arbitrary Number of Conditions</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Build-a-Search-String-with-an-Arbitrary-Number-of-Conditions/m-p/190272#M19394</link>
      <description>&lt;P&gt;Just want to mention, as an update, this is now trivial with Splunk 6.1 by using the &lt;CODE&gt;multiselect&lt;/CODE&gt; input type.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;input type="multiselect" token="my_animals"&amp;gt;
       &amp;lt;label&amp;gt;Types of animals in my soup&amp;lt;/label&amp;gt;
       &amp;lt;populatingSearch earliest="$earliest$" latest="$latest$" fieldForLabel="animal_name" fieldForValue="genus_species"&amp;gt;
                 index=fauna | stats dc(genus_species) by animal_name | fields animal_name genus_species
       &amp;lt;/populatingSearch&amp;gt;
       &amp;lt;default&amp;gt;monkeys,lions&amp;lt;/default&amp;gt;
       &amp;lt;delimiter&amp;gt;OR&amp;lt;/delimiter&amp;gt;
       &amp;lt;valuePrefix&amp;gt;(my_animal=&amp;lt;/valuePrefix&amp;gt;
       &amp;lt;valueSuffix&amp;gt;)&amp;lt;/valueSuffix&amp;gt;
  &amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now you can use the token &lt;CODE&gt;$my_animals$&lt;/CODE&gt; in a search and it will expanded into &lt;CODE&gt;(my_animal=lions) OR (my_animal=monkeys) OR (my_animal=tigers) OR (my_animal=bears)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jun 2014 03:41:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Build-a-Search-String-with-an-Arbitrary-Number-of-Conditions/m-p/190272#M19394</guid>
      <dc:creator>neiljpeterson</dc:creator>
      <dc:date>2014-06-26T03:41:34Z</dc:date>
    </item>
  </channel>
</rss>

