<?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 Replace only if commas exist in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Replace-only-if-commas-exist/m-p/481430#M134934</link>
    <description>&lt;P&gt;I have a dashboard (form) that I'm trying to allow a text field to accept single values or comma separated values that will be replaced by "* OR" right now when I first start up the dashboard and enter a single value, it just stays at "Search is waiting for input.." if I enter comma separated values it will run the search. I tried rapping the eval in a if statement to check for commas, but that didn't seem to do anything.&lt;/P&gt;

&lt;P&gt;Here is what I currently have:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="text" token="clientTransactionId" searchWhenChanged="true" id="webOrder"&amp;gt;
        &amp;lt;label&amp;gt;Transaction Id (for multiple use csv's):&amp;lt;/label&amp;gt;
        &amp;lt;change&amp;gt;
          &amp;lt;eval token="clientTransactionId_formatted"&amp;gt;if(like($clientTransactionId$, "%,%"),replace($clientTransactionId$,",","* OR"),$clientTransactionId$)&amp;lt;/eval&amp;gt;
        &amp;lt;/change&amp;gt;
      &amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And here is what I tried before:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;eval token="clientTransactionId_formatted"&amp;gt;replace($clientTransactionId$,",","* OR")&amp;lt;/eval&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I set this up to run? I need it to eval before search, there are too many transactions to filter after search has ran.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 21 Apr 2020 16:08:16 GMT</pubDate>
    <dc:creator>treverce</dc:creator>
    <dc:date>2020-04-21T16:08:16Z</dc:date>
    <item>
      <title>Replace only if commas exist</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-only-if-commas-exist/m-p/481430#M134934</link>
      <description>&lt;P&gt;I have a dashboard (form) that I'm trying to allow a text field to accept single values or comma separated values that will be replaced by "* OR" right now when I first start up the dashboard and enter a single value, it just stays at "Search is waiting for input.." if I enter comma separated values it will run the search. I tried rapping the eval in a if statement to check for commas, but that didn't seem to do anything.&lt;/P&gt;

&lt;P&gt;Here is what I currently have:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="text" token="clientTransactionId" searchWhenChanged="true" id="webOrder"&amp;gt;
        &amp;lt;label&amp;gt;Transaction Id (for multiple use csv's):&amp;lt;/label&amp;gt;
        &amp;lt;change&amp;gt;
          &amp;lt;eval token="clientTransactionId_formatted"&amp;gt;if(like($clientTransactionId$, "%,%"),replace($clientTransactionId$,",","* OR"),$clientTransactionId$)&amp;lt;/eval&amp;gt;
        &amp;lt;/change&amp;gt;
      &amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And here is what I tried before:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;eval token="clientTransactionId_formatted"&amp;gt;replace($clientTransactionId$,",","* OR")&amp;lt;/eval&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I set this up to run? I need it to eval before search, there are too many transactions to filter after search has ran.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 16:08:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-only-if-commas-exist/m-p/481430#M134934</guid>
      <dc:creator>treverce</dc:creator>
      <dc:date>2020-04-21T16:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: Replace only if commas exist</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-only-if-commas-exist/m-p/481431#M134935</link>
      <description>&lt;P&gt;Your code looks good and below statement is enough, replace occurs only if "," present in input otherwise clientTransactionId_formatted set to clientTransactionId. Can you post xml part of where token &lt;CODE&gt;clientTransactionId_formatted&lt;/CODE&gt; is used.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;eval token="clientTransactionId_formatted"&amp;gt;replace($clientTransactionId$,",","* OR")&amp;lt;/eval&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:03:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-only-if-commas-exist/m-p/481431#M134935</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-09-30T05:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: Replace only if commas exist</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-only-if-commas-exist/m-p/481432#M134936</link>
      <description>&lt;P&gt;This is what I have right now:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;search&amp;gt;
  &amp;lt;query&amp;gt;
    index=[redacted] (source="[redacted]*" OR source="[redacted]*") $clientTransactionId_formatted$* $actionType$ earliest=$date_range$ latest=now ...
  &amp;lt;/query&amp;gt;
  &amp;lt;earliest&amp;gt;-7d@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;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(Sorry I had to redact things for company security/privacy)&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 17:04:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-only-if-commas-exist/m-p/481432#M134936</guid>
      <dc:creator>treverce</dc:creator>
      <dc:date>2020-04-21T17:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: Replace only if commas exist</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-only-if-commas-exist/m-p/481433#M134937</link>
      <description>&lt;P&gt;Is searchWhenChanged="true" set for other token inputs? Are you using &lt;STRONG&gt;Submit&lt;/STRONG&gt; button? I don't see any issue with this text input. You can use below xml, it gives output for single value also.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="text" token="clientTransactionId" searchWhenChanged="true" id="webOrder"&amp;gt;
      &amp;lt;label&amp;gt;Transaction Id (for multiple use csv's):&amp;lt;/label&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;eval token="clientTransactionId_formatted"&amp;gt;replace($clientTransactionId$,",","* OR ")&amp;lt;/eval&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;html&amp;gt;
          &amp;lt;h3&amp;gt;Token:&amp;lt;/h3&amp;gt;
          &amp;lt;div class="custom-result-value"&amp;gt;$clientTransactionId_formatted$&amp;lt;/div&amp;gt;
      &amp;lt;/html&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Apr 2020 17:13:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-only-if-commas-exist/m-p/481433#M134937</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-04-21T17:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: Replace only if commas exist</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-only-if-commas-exist/m-p/481434#M134938</link>
      <description>&lt;P&gt;The more I play with it the more it seems this only happens if its a SINGLE transaction on the first query after I load the page, if I start with csv's then it works first start, just not when its the first query of a single transaction.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 17:15:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-only-if-commas-exist/m-p/481434#M134938</guid>
      <dc:creator>treverce</dc:creator>
      <dc:date>2020-04-21T17:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: Replace only if commas exist</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-only-if-commas-exist/m-p/481435#M134939</link>
      <description>&lt;P&gt;I think I see what is causing the issue, I have a second input (multi select) and if its "populating" when I enter into the first one, it doesn't trigger the eval. Not sure why those would be dependent one one another. I have a few static options defined, such as an "All" which is a * value as default.&lt;/P&gt;

&lt;P&gt;If I wait until after "populating" is completed, it works.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="multiselect" token="actionType" searchWhenChanged="true" id="action"&amp;gt;
  &amp;lt;label&amp;gt;Action Type:&amp;lt;/label&amp;gt;
  &amp;lt;choice value="*"&amp;gt;All&amp;lt;/choice&amp;gt;
  &amp;lt;choice value=""&amp;gt;------------------------------------------&amp;lt;/choice&amp;gt;
  &amp;lt;valuePrefix&amp;gt;"actionType:
  &amp;lt;/valuePrefix&amp;gt;
  &amp;lt;delimiter&amp;gt;
    OR
  &amp;lt;/delimiter&amp;gt;
  &amp;lt;fieldForLabel&amp;gt;ACTION_TYPE&amp;lt;/fieldForLabel&amp;gt;
  &amp;lt;fieldForValue&amp;gt;ACTION_TYPE&amp;lt;/fieldForValue&amp;gt;
  &amp;lt;search&amp;gt;
    &amp;lt;query&amp;gt;[REDACTED]&amp;lt;/query&amp;gt;
    &amp;lt;earliest&amp;gt;-5m&amp;lt;/earliest&amp;gt;
    &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;valueSuffix&amp;gt;"&amp;lt;/valueSuffix&amp;gt;
  &amp;lt;default&amp;gt;*&amp;lt;/default&amp;gt;
&amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Apr 2020 17:26:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-only-if-commas-exist/m-p/481435#M134939</guid>
      <dc:creator>treverce</dc:creator>
      <dc:date>2020-04-21T17:26:47Z</dc:date>
    </item>
  </channel>
</rss>

