<?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 Error when there are no rows to email on in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Error-when-there-are-no-rows-to-email-on/m-p/322038#M38541</link>
    <description>&lt;P&gt;I'm using the sendresults command to send emails to users during a saved search. However, when no rows are returned in the search, the command errors saying that it requires a email_to field. So, I created a quick patch which creates an argument for how to handle the no results case and if set will not signal an error. Let me know your thoughts.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host:Desktop me$ diff -ru sendresults sendresults-new
diff -ru sendresults/bin/sendresults.py sendresults-new/bin/sendresults.py
--- sendresults/bin/sendresults.py  2014-06-05 20:27:12.000000000 -0400
+++ sendresults-new/bin/sendresults.py  2017-04-08 09:37:30.000000000 -0400
@@ -196,9 +196,12 @@
    if maxrcpts &amp;lt; 1 :
        logger.error("More than emails would be generated than permitted. Increase your maxrcpts or change your search." % ())
        results = splunk.Intersplunk.generateErrorResults("Error : Field maxrcpts must be greater than 0. Increase your maxrcpts.")
-   elif d2.get('email_to') != len(results) :
-       logger.error("All results must contain a field named email_to with the intended recipient." % ())
-       results = splunk.Intersplunk.generateErrorResults("Error : All results must contain a field named email_to with the intended recipient.")
+   elif d2.get('email_to') != len(results) :
+       if toBool( getarg(argvals, “error_on_no_rows”, “true”) ):
+           logger.error("All results must contain a field named email_to with the intended recipient." % ())
+           results = splunk.Intersplunk.generateErrorResults("Error : All results must contain a field named email_to with the intended recipient.")
+       else:
+           logger.info(“Email not sent: No rows to process”)
    else :
        for event in results :
            d1[event['email_to']].append(event)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 08 Apr 2017 14:10:40 GMT</pubDate>
    <dc:creator>scottsavarese</dc:creator>
    <dc:date>2017-04-08T14:10:40Z</dc:date>
    <item>
      <title>Error when there are no rows to email on</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Error-when-there-are-no-rows-to-email-on/m-p/322038#M38541</link>
      <description>&lt;P&gt;I'm using the sendresults command to send emails to users during a saved search. However, when no rows are returned in the search, the command errors saying that it requires a email_to field. So, I created a quick patch which creates an argument for how to handle the no results case and if set will not signal an error. Let me know your thoughts.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host:Desktop me$ diff -ru sendresults sendresults-new
diff -ru sendresults/bin/sendresults.py sendresults-new/bin/sendresults.py
--- sendresults/bin/sendresults.py  2014-06-05 20:27:12.000000000 -0400
+++ sendresults-new/bin/sendresults.py  2017-04-08 09:37:30.000000000 -0400
@@ -196,9 +196,12 @@
    if maxrcpts &amp;lt; 1 :
        logger.error("More than emails would be generated than permitted. Increase your maxrcpts or change your search." % ())
        results = splunk.Intersplunk.generateErrorResults("Error : Field maxrcpts must be greater than 0. Increase your maxrcpts.")
-   elif d2.get('email_to') != len(results) :
-       logger.error("All results must contain a field named email_to with the intended recipient." % ())
-       results = splunk.Intersplunk.generateErrorResults("Error : All results must contain a field named email_to with the intended recipient.")
+   elif d2.get('email_to') != len(results) :
+       if toBool( getarg(argvals, “error_on_no_rows”, “true”) ):
+           logger.error("All results must contain a field named email_to with the intended recipient." % ())
+           results = splunk.Intersplunk.generateErrorResults("Error : All results must contain a field named email_to with the intended recipient.")
+       else:
+           logger.info(“Email not sent: No rows to process”)
    else :
        for event in results :
            d1[event['email_to']].append(event)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 Apr 2017 14:10:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Error-when-there-are-no-rows-to-email-on/m-p/322038#M38541</guid>
      <dc:creator>scottsavarese</dc:creator>
      <dc:date>2017-04-08T14:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: Error when there are no rows to email on</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Error-when-there-are-no-rows-to-email-on/m-p/322039#M38542</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;

&lt;P&gt;Thanks for that patch. It's a smart idea to the issue.&lt;/P&gt;

&lt;P&gt;We are working on a new release of the command and will incorporate this into it.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Derek.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Apr 2017 20:27:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Error-when-there-are-no-rows-to-email-on/m-p/322039#M38542</guid>
      <dc:creator>mockd</dc:creator>
      <dc:date>2017-04-08T20:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Error when there are no rows to email on</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Error-when-there-are-no-rows-to-email-on/m-p/322040#M38543</link>
      <description>&lt;P&gt;Thanks for the update... Looking forward to the new version &lt;/P&gt;</description>
      <pubDate>Sat, 08 Apr 2017 20:31:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Error-when-there-are-no-rows-to-email-on/m-p/322040#M38543</guid>
      <dc:creator>scottsavarese</dc:creator>
      <dc:date>2017-04-08T20:31:23Z</dc:date>
    </item>
  </channel>
</rss>

