<?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 How to implement an if/else condition in forms? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-an-if-else-condition-in-forms/m-p/76046#M4083</link>
    <description>&lt;P&gt;I have a form with a field called "Input" where a splunk user can type in a value-likeA,B,C etc. I want my form to run the search based on what the user inputs.&lt;/P&gt;

&lt;P&gt;so, the logic should be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if(input="X")
    then splunk search="index=!* index=*X...."
else
    splunk search="index=*..."
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I enforce that condition in my forms?
Thanks&lt;/P&gt;</description>
    <pubDate>Sat, 23 Oct 2010 01:04:19 GMT</pubDate>
    <dc:creator>sfmandmdev</dc:creator>
    <dc:date>2010-10-23T01:04:19Z</dc:date>
    <item>
      <title>How to implement an if/else condition in forms?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-an-if-else-condition-in-forms/m-p/76046#M4083</link>
      <description>&lt;P&gt;I have a form with a field called "Input" where a splunk user can type in a value-likeA,B,C etc. I want my form to run the search based on what the user inputs.&lt;/P&gt;

&lt;P&gt;so, the logic should be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if(input="X")
    then splunk search="index=!* index=*X...."
else
    splunk search="index=*..."
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I enforce that condition in my forms?
Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 23 Oct 2010 01:04:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-an-if-else-condition-in-forms/m-p/76046#M4083</guid>
      <dc:creator>sfmandmdev</dc:creator>
      <dc:date>2010-10-23T01:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement an if/else condition in forms?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-an-if-else-condition-in-forms/m-p/76047#M4084</link>
      <description>&lt;P&gt;You can probably do this by creating a macro for your search string (or a portion of your search string) and substituting in the form value to the macro argument.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Oct 2010 09:36:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-an-if-else-condition-in-forms/m-p/76047#M4084</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-10-24T09:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement an if/else condition in forms?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-an-if-else-condition-in-forms/m-p/76048#M4085</link>
      <description>&lt;P&gt;Maybe not quite what you're looking for, but have you considered changing from a free-form input to a dropdown menu?&lt;/P&gt;

&lt;P&gt;You likely would have to use the Advanced XML syntax, but with that approach, you can have different fields for the &lt;CODE&gt;label&lt;/CODE&gt; displayed to the user and the actual &lt;CODE&gt;value&lt;/CODE&gt; passed to the search. So in the dropdown, the label would be &lt;CODE&gt;X&lt;/CODE&gt;, but the "value" would be &lt;CODE&gt;index=!* index=*X....&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;Once you have that, you can use &lt;CODE&gt;stringreplace&lt;/CODE&gt; to insert that into your search string.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Oct 2010 11:11:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-an-if-else-condition-in-forms/m-p/76048#M4085</guid>
      <dc:creator>southeringtonp</dc:creator>
      <dc:date>2010-10-24T11:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement an if/else condition in forms?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-an-if-else-condition-in-forms/m-p/76049#M4086</link>
      <description>&lt;P&gt;I don't want to create a dropdown- because its a long and ever-changing list.Thanks though!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2010 00:24:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-an-if-else-condition-in-forms/m-p/76049#M4086</guid>
      <dc:creator>sfmandmdev</dc:creator>
      <dc:date>2010-10-26T00:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement an if/else condition in forms?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-an-if-else-condition-in-forms/m-p/76050#M4087</link>
      <description>&lt;P&gt;Okay, say my macro is foo($arg$) where arg is either:(index!=&lt;EM&gt;X index=$input$) OR (index=$input$&lt;/EM&gt;) depending on what the user enters(input is that value) &lt;/P&gt;

&lt;P&gt;How , then, in my form do i specify this if/else condition?&lt;BR /&gt;
if(input=X)&lt;BR /&gt;
 foo(index=$input$*)&lt;BR /&gt;
if(input!=X)&lt;BR /&gt;
  foo(index!=*X index=$input$)&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:19:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-an-if-else-condition-in-forms/m-p/76050#M4087</guid>
      <dc:creator>sfmandmdev</dc:creator>
      <dc:date>2020-09-28T09:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement an if/else condition in forms?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-an-if-else-condition-in-forms/m-p/76051#M4088</link>
      <description>&lt;P&gt;Fair enough. Just remember that you can use a search string to populate the list, so only the exception cases would necessarily require manual intervention.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2010 02:21:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-an-if-else-condition-in-forms/m-p/76051#M4088</guid>
      <dc:creator>southeringtonp</dc:creator>
      <dc:date>2010-10-26T02:21:58Z</dc:date>
    </item>
  </channel>
</rss>

