<?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: Passing multiselect token to the macros in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Passing-multiselect-token-to-the-macros/m-p/660744#M228125</link>
    <description>&lt;P&gt;You need to clarify the problem.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;The need to pass the multiselect values to macros2&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Forget multiselect values. &amp;nbsp;What is this &lt;FONT face="andale mono,times"&gt;macros2&lt;/FONT&gt;? &amp;nbsp;If this is yet another macro, SPL syntax forbids you from invoking a macro as parameter of another macro. &amp;nbsp;Do you mean macros2 represents the value from this multiselect token? &amp;nbsp;In that case, you cannot use single quote. (The outer quote in your pseudo code is also incorrect. &amp;nbsp;A macro is invoked by a pair of back ticks (`, not ').&lt;/P&gt;&lt;P&gt;It really doesn't matter whether the token is multiselect or of any other type. &amp;nbsp;The dashboard simply treat the resultant value as a string. &amp;nbsp;How the string is formatted depends on the INPUT settings, what is the delimiter, whether prefix and postfix are used, whether value prefix and value postfix are used, etc. &amp;nbsp;In this regard, I don't see any question that can be answered based on your description.&lt;/P&gt;</description>
    <pubDate>Fri, 13 Oct 2023 21:00:10 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2023-10-13T21:00:10Z</dc:date>
    <item>
      <title>Passing multiselect token to the macros</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-multiselect-token-to-the-macros/m-p/660626#M228083</link>
      <description>&lt;P&gt;Hi Splunkers,&lt;BR /&gt;&amp;nbsp; &amp;nbsp;I'm having the multiselect value that results need pass to a macros,&lt;BR /&gt;&amp;nbsp; &amp;nbsp;Can you please help for that?&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;The need is to pass the multiselect values to token $macros2$, where multiselect values is an macros itself,&lt;BR /&gt;&lt;BR /&gt;multi select values&lt;BR /&gt;1. value 1&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; value 2&lt;/P&gt;&lt;P&gt;3. value 3&lt;/P&gt;&lt;P&gt;4. All&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;search:&lt;/P&gt;&lt;P&gt;`macros1(`$macros2$`,&amp;nbsp; now(), -15d@d, *, virus, *, *, *)`&lt;BR /&gt;&lt;BR /&gt;Thanks in Advance!&lt;/P&gt;&lt;P&gt;Manoj Kumar S&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2023 10:03:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-multiselect-token-to-the-macros/m-p/660626#M228083</guid>
      <dc:creator>smanojkumar</dc:creator>
      <dc:date>2023-10-16T10:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: Passing multiselect token to the macros</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-multiselect-token-to-the-macros/m-p/660744#M228125</link>
      <description>&lt;P&gt;You need to clarify the problem.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;The need to pass the multiselect values to macros2&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Forget multiselect values. &amp;nbsp;What is this &lt;FONT face="andale mono,times"&gt;macros2&lt;/FONT&gt;? &amp;nbsp;If this is yet another macro, SPL syntax forbids you from invoking a macro as parameter of another macro. &amp;nbsp;Do you mean macros2 represents the value from this multiselect token? &amp;nbsp;In that case, you cannot use single quote. (The outer quote in your pseudo code is also incorrect. &amp;nbsp;A macro is invoked by a pair of back ticks (`, not ').&lt;/P&gt;&lt;P&gt;It really doesn't matter whether the token is multiselect or of any other type. &amp;nbsp;The dashboard simply treat the resultant value as a string. &amp;nbsp;How the string is formatted depends on the INPUT settings, what is the delimiter, whether prefix and postfix are used, whether value prefix and value postfix are used, etc. &amp;nbsp;In this regard, I don't see any question that can be answered based on your description.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2023 21:00:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-multiselect-token-to-the-macros/m-p/660744#M228125</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-10-13T21:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Passing multiselect token to the macros</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-multiselect-token-to-the-macros/m-p/660813#M228146</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Sorry for the mistake!&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;`macros1(`$macros2$`,&amp;nbsp; now(), -15d@d, *, virus, *, *, *)`&lt;BR /&gt;&lt;BR /&gt;The values to be passed in macros2 is multiselect, I get error if i passed two values at a time, because each values passed is an individual macros which has different search in it. I need OR condition to be performed on that case.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thanks in Advance!&lt;/P&gt;&lt;P&gt;Manoj Kumar S&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2023 06:50:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-multiselect-token-to-the-macros/m-p/660813#M228146</guid>
      <dc:creator>smanojkumar</dc:creator>
      <dc:date>2023-10-16T06:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: Passing multiselect token to the macros</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-multiselect-token-to-the-macros/m-p/660946#M228189</link>
      <description>&lt;P&gt;First, you need to be very precise if you are to cite code snippet, even for pseudo code. &amp;nbsp;&lt;SPAN&gt;&lt;FONT face="andale mono,times"&gt;`macros1(`$macros2$`,&amp;nbsp; now(), -15d@d, *, virus, *, *, *)`&lt;/FONT&gt; is simply incorrect because Splunk will give you an error about macro &lt;U&gt;&lt;FONT face="andale mono,times"&gt;macro1(&lt;/FONT&gt;&lt;/U&gt; not defined or no permission, or a similar error. &amp;nbsp;When you open a macro invocation with a back tick, Splunk expects you to close it with the closest back tick. &amp;nbsp;In your sample, Splunk will be looking for two macros, one named &lt;U&gt;&lt;FONT face="andale mono,times"&gt;macros1(&lt;/FONT&gt;&lt;/U&gt;, the other named &lt;U&gt;&lt;FONT face="andale mono,times"&gt;,&amp;nbsp; now(), -15d@d, *, virus, *, *, *)&lt;/FONT&gt;&lt;/U&gt;. &amp;nbsp;I am certain that none of them exist.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Second, do not name your token so similarly to the macro name so you don't confuse yourself during diagnosis. &amp;nbsp;If this is pseudo code, do not name mock token so close to mock macro name, so you don't confuse volunteers here who are trying to help diagnose.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Third, if a parameter is causing error in an macro, you need to explain how this parameter is being used inside that macro as well as how macro is invoked in actual search, so volunteers here do not waste their time reading your mind.&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;SPAN&gt;I need OR condition to be performed on that case.&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Suppose your input has delimiter &lt;U&gt;OR&lt;/U&gt;, and you first select &lt;U&gt;stringA&lt;/U&gt;, then select &lt;U&gt;stringB&lt;/U&gt;. Nothing else is defined. &amp;nbsp;Your token would contain &lt;U&gt;stringA OR stringB&lt;/U&gt;, as a bare string. &amp;nbsp;Suppose your macro1(1) is&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;search $mytok$&lt;/LI-CODE&gt;&lt;P&gt;&lt;U&gt;mytok&lt;/U&gt; being the token name you set in the macro (again, do not name it very close to the macro's own name), and if the search that invokes the macro is&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| `macro1($multiselect_tok$)`&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;$multiselect_tok$ being the name of the token in the multiselect input. (You can name it semantically, but never too close to the macro's own name.) &amp;nbsp;There will be no problem with the search. &amp;nbsp;It will behave as if you entered&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| search stringA OR stringB&lt;/LI-CODE&gt;&lt;P&gt;Without relevant information about the macro and about the search that uses the macro, your question is unanswerable.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2023 23:47:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-multiselect-token-to-the-macros/m-p/660946#M228189</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-10-16T23:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: Passing multiselect token to the macros</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-multiselect-token-to-the-macros/m-p/661004#M228213</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;I just renamed some fields, here is the exact one, I had modified few things based your reply.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;&amp;lt;input type="checkbox" token="index_scope" searchWhenChanged="true"&amp;gt;
&amp;lt;label&amp;gt;Choose console&amp;lt;/label&amp;gt;
&amp;lt;choice value="1T*"&amp;gt;Standard&amp;lt;/choice&amp;gt;
&amp;lt;choice value="2A*"&amp;gt;Scada&amp;lt;/choice&amp;gt;
&amp;lt;choice value="2S*"&amp;gt;AWS&amp;lt;/choice&amp;gt;
&amp;lt;default&amp;gt;1T*&amp;lt;/default&amp;gt;
&amp;lt;initialValue&amp;gt;1T*&amp;lt;/initialValue&amp;gt;
&amp;lt;/input&amp;gt;|&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;Here is the search&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;`compliance($index_scope$, now(), $timerange$, $scope$, $origin$, $country$, $cacp$)`&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's not working as expected in multiselect, earlier for dropdown its working good.&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 12:02:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-multiselect-token-to-the-macros/m-p/661004#M228213</guid>
      <dc:creator>smanojkumar</dc:creator>
      <dc:date>2023-10-17T12:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: Passing multiselect token to the macros</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-multiselect-token-to-the-macros/m-p/661063#M228237</link>
      <description>&lt;P&gt;You didn't show how $index_scope$ is used inside the macro. &amp;nbsp;Using hints from the sample values, that dropdown based on these values used to work as desired, and from semantic heuristics, as well as your choice of token name, I can only speculate that inside you macro `compliance(7)`, you use the first input in a search command, i.e., (I'll call the first input $input1$ - which correspond to $mytok$ in my previous illustration), the macro has a command like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=$input1$&lt;/LI-CODE&gt;&lt;P&gt;The following will be based on this speculation. &amp;nbsp;If this is too far from the real macro code, the analysis will not apply although I will try to be as general as can be meaningfully presented. (As you can see, I wouldn't have to make wild guesses which may well be incorrect had you provided relative information.)&lt;/P&gt;&lt;P&gt;The second part of the analysis will focus on input options that you can set when setting a multiselect inputs as I exemplified earlier.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="token-options.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/27616i0A8D511AF2D89848/image-size/medium?v=v2&amp;amp;px=400" role="button" title="token-options.png" alt="token-options.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In your sample code, none of these is set. &amp;nbsp;In that case, Splunk will use a space as default delimiter, and give no prefix and no suffix. &amp;nbsp;I have not found the tutorial about input, but definitive information is in &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Viz/PanelreferenceforSimplifiedXML#input_.28form.29" target="_blank" rel="noopener"&gt;input (form)&lt;/A&gt;. &amp;nbsp;To help you understand how these choices affect resultant token, I drafted this test dashboard for you to play with:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;form version="1.1"&amp;gt;
  &amp;lt;label&amp;gt;Checkbox test&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="checkbox" token="index_scope" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;Choose console&amp;lt;/label&amp;gt;
      &amp;lt;choice value="1T*"&amp;gt;Standard&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="2A*"&amp;gt;Scada&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="2S*"&amp;gt;AWS&amp;lt;/choice&amp;gt;
      &amp;lt;default&amp;gt;1T*&amp;lt;/default&amp;gt;
      &amp;lt;initialValue&amp;gt;1T*&amp;lt;/initialValue&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults
| eval index_scope = "$index_scope$"&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;The third part of analysis is straightforward with search command. &amp;nbsp;Understandably, if you select "Standard" from a dropdown, or if only Standard is checked, your macro will get the command&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;search index=1T*&lt;/LI-CODE&gt;&lt;P&gt;(The search command is implied if it is on the first line. &amp;nbsp;Otherwise you must write it explicitly.) &amp;nbsp;Now, if you select "Standard" and "Scada", the macro will get&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;search index=1T* 2A*&lt;/LI-CODE&gt;&lt;P&gt;I suspect that you are expecting something like &lt;U&gt;&lt;FONT face="andale mono,times"&gt;index=1T* OR index=2A*&lt;/FONT&gt;&lt;/U&gt; instead. &amp;nbsp;Is this correct? &amp;nbsp;One way to do this, obviously, is to set Delimiter to "&lt;U&gt;&lt;FONT face="andale mono,times"&gt; OR&amp;nbsp;&lt;/FONT&gt;&lt;/U&gt;", and value prefix to "index=". &amp;nbsp;Note the space before and after keyword "OR" is important.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;form version="1.1" theme="light"&amp;gt;
  &amp;lt;label&amp;gt;Checkbox test&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="checkbox" token="index_scope" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;Choose console&amp;lt;/label&amp;gt;
      &amp;lt;choice value="1T*"&amp;gt;Standard&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="2A*"&amp;gt;Scada&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="2S*"&amp;gt;AWS&amp;lt;/choice&amp;gt;
      &amp;lt;default&amp;gt;1T*&amp;lt;/default&amp;gt;
      &amp;lt;initialValue&amp;gt;1T*&amp;lt;/initialValue&amp;gt;
      &amp;lt;delimiter&amp;gt; OR &amp;lt;/delimiter&amp;gt;
      &amp;lt;valuePrefix&amp;gt;index=&amp;lt;/valuePrefix&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults
| eval index_scope = "$index_scope$"&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 17:08:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-multiselect-token-to-the-macros/m-p/661063#M228237</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-10-17T17:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: Passing multiselect token to the macros</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-multiselect-token-to-the-macros/m-p/661075#M228244</link>
      <description>&lt;P&gt;Another option would&amp;nbsp; be to set the delimiter to a comma in the multiselect then in the macro use the IN keyword like this ...&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index IN ($index_scope$) ... #The rest of the macro# ....&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 17 Oct 2023 17:56:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-multiselect-token-to-the-macros/m-p/661075#M228244</guid>
      <dc:creator>fredclown</dc:creator>
      <dc:date>2023-10-17T17:56:16Z</dc:date>
    </item>
  </channel>
</rss>

