<?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: Evaluating form field if not null? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Evaluating-form-field-if-not-null/m-p/18170#M564</link>
    <description>&lt;P&gt;That was the answer I was looking for:&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;in Splunk 6, for the first method to work, you'll need to include a blank &lt;BR /&gt;
 &lt;CODE&gt;&amp;lt;default&amp;gt;&amp;lt;/default&amp;gt;&lt;/CODE&gt;&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;Had some strange behaviour in my dashboards, because I used to make an "optional" search for a keyword appended to the base search (&lt;CODE&gt;| search $something$&lt;/CODE&gt;) - and by default, splunk &amp;lt;6 omitted an empty input. Now the mentioned statement brings back this behaviour - thanks for the hint &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 19 May 2014 15:29:24 GMT</pubDate>
    <dc:creator>tugnet</dc:creator>
    <dc:date>2014-05-19T15:29:24Z</dc:date>
    <item>
      <title>Evaluating form field if not null?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Evaluating-form-field-if-not-null/m-p/18164#M558</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;I am trying to include the contents of a form field into an AND search clause only if the form field is not null.&lt;/P&gt;

&lt;P&gt;So, say there are three input fields: field1, field2, and field3.&lt;/P&gt;

&lt;P&gt;If the user enters stuff into field1 and field3, I want to search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=stuff search1=field1 AND search3=field3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But my search looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=stuff search1=field1 AND search2=field2 AND search3=field3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So, the example search will return no results because search2 does not equal ""&lt;/P&gt;

&lt;P&gt;Is there a way I use &lt;EM&gt;eval isnotnull()&lt;/EM&gt; to remove a field from my search string if the user doesn't enter anything?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2010 04:06:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Evaluating-form-field-if-not-null/m-p/18164#M558</guid>
      <dc:creator>Tisiphone_1</dc:creator>
      <dc:date>2010-07-22T04:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluating form field if not null?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Evaluating-form-field-if-not-null/m-p/18165#M559</link>
      <description>&lt;P&gt;Maybe something like this &lt;CODE&gt;eval newfield = if(field == "", "*", field) | search1=newfield&lt;/CODE&gt; ?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2010 05:02:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Evaluating-form-field-if-not-null/m-p/18165#M559</guid>
      <dc:creator>gljiva</dc:creator>
      <dc:date>2010-07-22T05:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluating form field if not null?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Evaluating-form-field-if-not-null/m-p/18166#M560</link>
      <description>&lt;P&gt;Hmm,&lt;/P&gt;

&lt;P&gt;So I am now doing:&lt;/P&gt;

&lt;P&gt;index=stuff | eval newfield = if(field1 == "", "*", field1) | index=stuff (search1=newfield OR search2=field2)&lt;/P&gt;

&lt;P&gt;But this throws a failhandler error.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2010 05:50:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Evaluating-form-field-if-not-null/m-p/18166#M560</guid>
      <dc:creator>Tisiphone_1</dc:creator>
      <dc:date>2010-07-22T05:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluating form field if not null?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Evaluating-form-field-if-not-null/m-p/18167#M561</link>
      <description>&lt;P&gt;There are at least two ways around this:&lt;/P&gt;

&lt;P&gt;The best is to use &lt;CODE&gt;prefix&lt;/CODE&gt; and &lt;CODE&gt;suffix&lt;/CODE&gt; values in your form field. In simple XML, this would look like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="text" token="field3"&amp;gt;
  &amp;lt;prefix&amp;gt;search3="&amp;lt;/prefix&amp;gt;
  &amp;lt;suffix&amp;gt;"&amp;lt;/suffix&amp;gt;
&amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and your searchTemplate  could look like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search1=$field1$ search2=$field2 $field3$ 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This method will only include $field3$ if the user typed a value at all. The other method would be to set a default:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="text" token="field3"&amp;gt;
    &amp;lt;default&amp;gt;*&amp;lt;/default&amp;gt;
&amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and searchTemplate:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search1=$field1$ search2=$field2$ search3=$field$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This actually behaves slightly differently as it requires that &lt;CODE&gt;search3&lt;/CODE&gt; must have &lt;EM&gt;some&lt;/EM&gt; value, while the previous will return results where &lt;CODE&gt;search3&lt;/CODE&gt; is not set at all.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2010 06:12:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Evaluating-form-field-if-not-null/m-p/18167#M561</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-07-22T06:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluating form field if not null?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Evaluating-form-field-if-not-null/m-p/18168#M562</link>
      <description>&lt;P&gt;I think that the former is working. It became more complicated because I made the operator (and/or) a variable too, but I did:&lt;/P&gt;

&lt;P&gt;&lt;INPUT type="text" token="field3" /&gt;&lt;BR /&gt;
  &lt;PREFIX&gt;$operator$ search3="&lt;/PREFIX&gt;&lt;BR /&gt;
  &lt;SUFFIX&gt;"&lt;/SUFFIX&gt;&lt;BR /&gt;
&lt;/P&gt;

&lt;P&gt;and it worked!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2010 06:38:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Evaluating-form-field-if-not-null/m-p/18168#M562</guid>
      <dc:creator>Tisiphone_1</dc:creator>
      <dc:date>2010-07-22T06:38:46Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluating form field if not null?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Evaluating-form-field-if-not-null/m-p/18169#M563</link>
      <description>&lt;P&gt;Years later this still helped me resolve an issue where I needed an if statement against a search rather than storing a result in an eval. The only difference is in Splunk 6, for the first method to work, you'll need to include a blank &lt;DEFAULT&gt;&lt;/DEFAULT&gt;.&lt;/P&gt;

&lt;P&gt;To elaborate further, I have a form that populates a dropdown menu with a lookup table. The lookup table stores a search as the value for each dropdown entry. The dashboard serves the purpose of updating, deleting and adding new entries. Using prefix &amp;amp; suffix let me ignore form fields thus deleting lookup table entries instead of adding.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2014 16:47:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Evaluating-form-field-if-not-null/m-p/18169#M563</guid>
      <dc:creator>smashedpumpkins</dc:creator>
      <dc:date>2014-02-17T16:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluating form field if not null?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Evaluating-form-field-if-not-null/m-p/18170#M564</link>
      <description>&lt;P&gt;That was the answer I was looking for:&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;in Splunk 6, for the first method to work, you'll need to include a blank &lt;BR /&gt;
 &lt;CODE&gt;&amp;lt;default&amp;gt;&amp;lt;/default&amp;gt;&lt;/CODE&gt;&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;Had some strange behaviour in my dashboards, because I used to make an "optional" search for a keyword appended to the base search (&lt;CODE&gt;| search $something$&lt;/CODE&gt;) - and by default, splunk &amp;lt;6 omitted an empty input. Now the mentioned statement brings back this behaviour - thanks for the hint &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 May 2014 15:29:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Evaluating-form-field-if-not-null/m-p/18170#M564</guid>
      <dc:creator>tugnet</dc:creator>
      <dc:date>2014-05-19T15:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: Evaluating form field if not null?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Evaluating-form-field-if-not-null/m-p/18171#M565</link>
      <description>&lt;P&gt;That is pure magic! looked for this for so much time! thanks.&lt;BR /&gt;
Actually from all other discussions in Splunk answers, it seems like there is no way to set empty token in search.&lt;BR /&gt;
Apparently it works.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2016 10:27:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Evaluating-form-field-if-not-null/m-p/18171#M565</guid>
      <dc:creator>ehudb</dc:creator>
      <dc:date>2016-04-04T10:27:03Z</dc:date>
    </item>
  </channel>
</rss>

