<?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 Create search macro with return value in Knowledge Management</title>
    <link>https://community.splunk.com/t5/Knowledge-Management/Create-search-macro-with-return-value/m-p/456476#M4053</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I want to create my search macro to return new field.&lt;BR /&gt;
Example:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;my_search_macro("1")&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I want to return a new field, test, that contains "your value is " + $arg$&lt;/P&gt;

&lt;P&gt;What I'm tried to write in search macro definition:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;|eval test="your value is " + $arg$&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;But when I execute my search command as follow:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;|makeresults | eval msg = &lt;CODE&gt;my_search_macro("1")&lt;/CODE&gt; | table msg &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I got an error.&lt;BR /&gt;
So how can I simply create search macro with return value? &lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 01:10:50 GMT</pubDate>
    <dc:creator>yko84109</dc:creator>
    <dc:date>2020-09-30T01:10:50Z</dc:date>
    <item>
      <title>Create search macro with return value</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Create-search-macro-with-return-value/m-p/456476#M4053</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I want to create my search macro to return new field.&lt;BR /&gt;
Example:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;my_search_macro("1")&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I want to return a new field, test, that contains "your value is " + $arg$&lt;/P&gt;

&lt;P&gt;What I'm tried to write in search macro definition:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;|eval test="your value is " + $arg$&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;But when I execute my search command as follow:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;|makeresults | eval msg = &lt;CODE&gt;my_search_macro("1")&lt;/CODE&gt; | table msg &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I got an error.&lt;BR /&gt;
So how can I simply create search macro with return value? &lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:10:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Create-search-macro-with-return-value/m-p/456476#M4053</guid>
      <dc:creator>yko84109</dc:creator>
      <dc:date>2020-09-30T01:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: Create search macro with return value</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Create-search-macro-with-return-value/m-p/456477#M4054</link>
      <description>&lt;P&gt;Macros are simple text substitutions, not functions.  Your example query expands to &lt;CODE&gt;| makeresults | eval msg = eval test="your value is foo" | table msg&lt;/CODE&gt;, which is why you get an error. Try changing the macro to &lt;CODE&gt;"your value is " + $arg$&lt;/CODE&gt; and be sure to check the "eval" box.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jul 2019 14:39:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Create-search-macro-with-return-value/m-p/456477#M4054</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-07-04T14:39:17Z</dc:date>
    </item>
  </channel>
</rss>

