<?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: How to do error handling for wrong search query in  HTML view in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-error-handling-for-wrong-search-query-in-HTML-view/m-p/334796#M99511</link>
    <description>&lt;P&gt;@jsharma123, this is elegant. You can go ahead and accept your own answer to mark this question as answered!&lt;/P&gt;

&lt;P&gt;In Splunk there are &lt;CODE&gt;depends&lt;/CODE&gt; and &lt;CODE&gt;rejects&lt;/CODE&gt; attributed which allow you to &lt;STRONG&gt;show&lt;/STRONG&gt; or &lt;STRONG&gt;hide&lt;/STRONG&gt; a dashboard element based on whether the token is set or not. You can refer to Null Search Swapper example in Splunk Dashboard examples app to see how that works in Simple XML and then convert the same to HTML as per your need. Since it is in similar lines with what you have already done in svg, I will let it up to you whether you want that solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Oct 2017 07:26:35 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-10-27T07:26:35Z</dc:date>
    <item>
      <title>How to do error handling for wrong search query in  HTML view</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-error-handling-for-wrong-search-query-in-HTML-view/m-p/334792#M99507</link>
      <description>&lt;P&gt;HI ,&lt;/P&gt;

&lt;P&gt;I have a html dashboard which update a d3 graph on text input change ,&lt;BR /&gt;
This text input is added to my search query in search manager. &lt;BR /&gt;
But when The query is wrong or there is no data  , I need to do error handling .&lt;BR /&gt;
How can i check for this situation ?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 10:17:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-error-handling-for-wrong-search-query-in-HTML-view/m-p/334792#M99507</guid>
      <dc:creator>jsharma123</dc:creator>
      <dc:date>2017-10-26T10:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to do error handling for wrong search query in  HTML view</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-error-handling-for-wrong-search-query-in-HTML-view/m-p/334793#M99508</link>
      <description>&lt;P&gt;@jsharma123, what is the error handling you need to perform?&lt;/P&gt;

&lt;P&gt;1) Hide D3 visualization on Error or No Results.&lt;BR /&gt;
2) Handle No Results with your Template output like "No Results Found. Please change the filter criteria."&lt;BR /&gt;
3) Perform Text Box input Regular Expression based validation to allow only valid input&lt;BR /&gt;
4) Invoke JavaScript based code for custom Error Handling&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 11:19:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-error-handling-for-wrong-search-query-in-HTML-view/m-p/334793#M99508</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-10-26T11:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to do error handling for wrong search query in  HTML view</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-error-handling-for-wrong-search-query-in-HTML-view/m-p/334794#M99509</link>
      <description>&lt;P&gt;@niketnilay&lt;/P&gt;

&lt;P&gt;Thanks for your reply,&lt;BR /&gt;
I want to do "Handle No Results with your Template output like "No Results Found. Please change the filter criteria." &lt;BR /&gt;
and as follow up action it should "Hide D3 visualization on Error or No Results."&lt;/P&gt;

&lt;P&gt;I am using &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var myResults =search.data('results', { // get the data from that search
                    output_mode: 'json_rows',
                     count: 0 // get all results
                 });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will not even get called in case of no data.&lt;/P&gt;

&lt;P&gt;I am looking at Search:done as well but then how to get my data when result has data?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;myResults.on("search:done", function() {
   console.log("Woohoo, all done!");
 });
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Oct 2017 05:08:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-error-handling-for-wrong-search-query-in-HTML-view/m-p/334794#M99509</guid>
      <dc:creator>jsharma123</dc:creator>
      <dc:date>2017-10-27T05:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to do error handling for wrong search query in  HTML view</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-error-handling-for-wrong-search-query-in-HTML-view/m-p/334795#M99510</link>
      <description>&lt;P&gt;I found a solution &lt;/P&gt;

&lt;P&gt;This is what I did&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search.on("search:done", function(state,job) {
           if(state.content.resultCount==0){
                d3.select("#body").select("svg").remove();

                var newSvg= d3.select("#body").append("svg")
                .attr("width", width + margin.right + margin.left)
                .attr("height", height + margin.top + margin.bottom);

                var rect = newSvg.append('rect').transition().duration(10).attr('width', 1050)
                .attr('height', 50)
                .attr('x', 40)
                .attr('y', 100)
                .style('fill', 'white')
                var text = newSvg.append('text').text('The query returned No result')
                .attr('x', 50)
                .attr('y', 150)
                .attr('fill', 'black')
                .attr("font-family", "sans-serif")
                .style("font-size", "34px");
           }
         });

var myResults =search.data('results', { // get the data from that search
                     output_mode: 'json_rows',
                     count: 0 // get all results
                 });

myResults.on("data", function() {

    console.log("Has data? ", myResults.hasData());

}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Oct 2017 06:17:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-error-handling-for-wrong-search-query-in-HTML-view/m-p/334795#M99510</guid>
      <dc:creator>jsharma123</dc:creator>
      <dc:date>2017-10-27T06:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to do error handling for wrong search query in  HTML view</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-error-handling-for-wrong-search-query-in-HTML-view/m-p/334796#M99511</link>
      <description>&lt;P&gt;@jsharma123, this is elegant. You can go ahead and accept your own answer to mark this question as answered!&lt;/P&gt;

&lt;P&gt;In Splunk there are &lt;CODE&gt;depends&lt;/CODE&gt; and &lt;CODE&gt;rejects&lt;/CODE&gt; attributed which allow you to &lt;STRONG&gt;show&lt;/STRONG&gt; or &lt;STRONG&gt;hide&lt;/STRONG&gt; a dashboard element based on whether the token is set or not. You can refer to Null Search Swapper example in Splunk Dashboard examples app to see how that works in Simple XML and then convert the same to HTML as per your need. Since it is in similar lines with what you have already done in svg, I will let it up to you whether you want that solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 07:26:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-error-handling-for-wrong-search-query-in-HTML-view/m-p/334796#M99511</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-10-27T07:26:35Z</dc:date>
    </item>
  </channel>
</rss>

