<?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: Manipulate a Token String in a Form in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Manipulate-a-Token-String-in-a-Form/m-p/186851#M11594</link>
    <description>&lt;P&gt;This should be doable using an eval-based macro. For example, if you wanted to turn a token containing "error,warn" into "error OR warn" you can run this search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal `commasToOr("error,warn")`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;using this eval-based macro definition:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[commasToOr(1)]
args = token
definition = replace("$token$", ",", " OR ")
iseval = 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Looking at the job inspector, the search that was actually executed is this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search index=_internal error OR warn
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can apply the same strategy to adding single quotes using replace, and this should work from your form as well.&lt;/P&gt;</description>
    <pubDate>Thu, 13 Mar 2014 23:00:54 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-03-13T23:00:54Z</dc:date>
    <item>
      <title>Manipulate a Token String in a Form</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Manipulate-a-Token-String-in-a-Form/m-p/186849#M11592</link>
      <description>&lt;P&gt;I would like to modify the token a user inputs in a form using rex commands so that I can insert it into the search later.  For instance,  if the user enters AC123,AC456 in the form field, I would want that to be plugged into the search as 'AC123','AC456'. Is there anyway to do this? &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="text" token="account" searchWhenChanged="false"&amp;gt;
  &amp;lt;label&amp;gt;Account&amp;lt;/label&amp;gt;
  &amp;lt;default&amp;gt;AC123,AC456&amp;lt;/default&amp;gt;
&amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Mar 2014 18:43:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Manipulate-a-Token-String-in-a-Form/m-p/186849#M11592</guid>
      <dc:creator>mjosen</dc:creator>
      <dc:date>2014-03-13T18:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate a Token String in a Form</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Manipulate-a-Token-String-in-a-Form/m-p/186850#M11593</link>
      <description>&lt;P&gt;You can do the manipulation within the search itself where you'll be using it. E.g. (assuming you use search filter using token like account=$account$&lt;/P&gt;

&lt;P&gt;index=abc sourcetype=xyz [search index=abc | head 1 | eval account="'$account$'" | table account | eval account=replace(account,",","','")]...&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2014 19:44:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Manipulate-a-Token-String-in-a-Form/m-p/186850#M11593</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-03-13T19:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate a Token String in a Form</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Manipulate-a-Token-String-in-a-Form/m-p/186851#M11594</link>
      <description>&lt;P&gt;This should be doable using an eval-based macro. For example, if you wanted to turn a token containing "error,warn" into "error OR warn" you can run this search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal `commasToOr("error,warn")`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;using this eval-based macro definition:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[commasToOr(1)]
args = token
definition = replace("$token$", ",", " OR ")
iseval = 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Looking at the job inspector, the search that was actually executed is this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search index=_internal error OR warn
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can apply the same strategy to adding single quotes using replace, and this should work from your form as well.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2014 23:00:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Manipulate-a-Token-String-in-a-Form/m-p/186851#M11594</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-03-13T23:00:54Z</dc:date>
    </item>
  </channel>
</rss>

