<?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: Custom Javascript throw exception: &amp;quot;Splunk is not defined&amp;quot; in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Javascript-throw-exception-quot-Splunk-is-not-defined/m-p/176012#M10902</link>
    <description>&lt;P&gt;yes, sorry.. this is the link: &lt;A href="http://answers.splunk.com/answers/83206/color-in-a-table-based-on-values.html"&gt;http://answers.splunk.com/answers/83206/color-in-a-table-based-on-values.html&lt;/A&gt; &lt;/P&gt;</description>
    <pubDate>Mon, 11 May 2015 07:13:00 GMT</pubDate>
    <dc:creator>barakakha</dc:creator>
    <dc:date>2015-05-11T07:13:00Z</dc:date>
    <item>
      <title>Custom Javascript throw exception: "Splunk is not defined"</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Javascript-throw-exception-quot-Splunk-is-not-defined/m-p/176010#M10900</link>
      <description>&lt;P&gt;I'm trying to add custom Javascript to my simple XML dashboard (as explained &lt;A href="http://answers.splunk.com/answers/83206/color-in-a-table-based-on-values.html"&gt;here&lt;/A&gt;) but when it start running it throw an exception "Splunk is not defined". &lt;/P&gt;

&lt;P&gt;This is my js code with some modification to find why its not running:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;try{
    if( Splunk.Module.SimpleResultsTable ){
    Splunk.Module.SimpleResultsTable = $.klass(Splunk.Module.SimpleResultsTable, {
        renderResults: function($super, htmlFragment) {
            $super(htmlFragment);

            if (this.getInferredEntityName()=="events") {
                this.renderedCount = $("tr", this.container).length - 1;
            }

            $('#highlight td').each(function() {
                $(this).attr("data-value",$(this).html().trim());
            });
        }
    });
 }
}
catch(err){
    alert(err.message);
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;what am i doing wrong?&lt;/P&gt;</description>
      <pubDate>Sun, 10 May 2015 15:33:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Javascript-throw-exception-quot-Splunk-is-not-defined/m-p/176010#M10900</guid>
      <dc:creator>barakakha</dc:creator>
      <dc:date>2015-05-10T15:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Javascript throw exception: "Splunk is not defined"</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Javascript-throw-exception-quot-Splunk-is-not-defined/m-p/176011#M10901</link>
      <description>&lt;P&gt;As explained where? Did you intend to include a link?&lt;/P&gt;</description>
      <pubDate>Sun, 10 May 2015 18:32:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Javascript-throw-exception-quot-Splunk-is-not-defined/m-p/176011#M10901</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2015-05-10T18:32:10Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Javascript throw exception: "Splunk is not defined"</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Javascript-throw-exception-quot-Splunk-is-not-defined/m-p/176012#M10902</link>
      <description>&lt;P&gt;yes, sorry.. this is the link: &lt;A href="http://answers.splunk.com/answers/83206/color-in-a-table-based-on-values.html"&gt;http://answers.splunk.com/answers/83206/color-in-a-table-based-on-values.html&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2015 07:13:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Javascript-throw-exception-quot-Splunk-is-not-defined/m-p/176012#M10902</guid>
      <dc:creator>barakakha</dc:creator>
      <dc:date>2015-05-11T07:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Javascript throw exception: "Splunk is not defined"</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Javascript-throw-exception-quot-Splunk-is-not-defined/m-p/176013#M10903</link>
      <description>&lt;P&gt;Your javascript file needs to load some dependencies. Right now, you are telling the browser to out of the blue use an object called "Splunk", but you didn't tell it where to find that object. Have a look &lt;A href="http://dev.splunk.com/view/webframework-splunkjsstack/SP-CAAAESY"&gt;here&lt;/A&gt; at the third gray box to see that your .js needs to have roughly the following format:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
"splunkjs/ready!",
"splunkjs/mvc/chartview"
], function(mvc) {
    var Chart = require("splunkjs/mvc/chartview"); // otherwise "Chart" would be undefined etc.
    // further js goes here
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;splunkjs/ready!&lt;/CODE&gt; is needed to use Splunk in your js code I believe, so placing the code you currently have where the comment indicates should do the trick for you, at least as far as the error you currently have is concerned.&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2015 08:54:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Javascript-throw-exception-quot-Splunk-is-not-defined/m-p/176013#M10903</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2015-05-11T08:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Javascript throw exception: "Splunk is not defined"</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Javascript-throw-exception-quot-Splunk-is-not-defined/m-p/176014#M10904</link>
      <description>&lt;P&gt;Thank you!! that was it..&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2015 11:27:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Custom-Javascript-throw-exception-quot-Splunk-is-not-defined/m-p/176014#M10904</guid>
      <dc:creator>barakakha</dc:creator>
      <dc:date>2015-05-11T11:27:02Z</dc:date>
    </item>
  </channel>
</rss>

