<?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 use JavaScript code in Splunk Cloud dashboard ? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-JavaScript-code-in-Splunk-Cloud-dashboard/m-p/627733#M51448</link>
    <description>&lt;P&gt;I'm looking for this as well, for colocation reasons. But so far I haven't found a way.&lt;/P&gt;&lt;P&gt;For people playing along at home: web.conf has a few options for dashboards (like dashboard_html_allow_embeddable_content), but seemingly nothing to allow embedding scripts.&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jan 2023 12:39:42 GMT</pubDate>
    <dc:creator>spunk_enthusias</dc:creator>
    <dc:date>2023-01-20T12:39:42Z</dc:date>
    <item>
      <title>How to use JavaScript code in Splunk Cloud dashboard ?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-JavaScript-code-in-Splunk-Cloud-dashboard/m-p/368500#M24070</link>
      <description>&lt;P&gt;I would like to fetch &lt;STRONG&gt;query string&lt;/STRONG&gt; value through script in &lt;STRONG&gt;splunk cloud&lt;/STRONG&gt; dashboard or in report so how it can be possible ?&lt;/P&gt;

&lt;P&gt;For ex. &lt;A href="http://www.splunkcloud.com"&gt;www.splunkcloud.com&lt;/A&gt; ? &lt;STRONG&gt;q=TRY&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Dashboard source code of cloud&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/3586iD76D3E7DB715DEFF/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;BR /&gt;
I am not able to call any script. its giving error.&lt;/P&gt;

&lt;P&gt;If i want to use &lt;STRONG&gt;q's&lt;/STRONG&gt; value &lt;STRONG&gt;TRY&lt;/STRONG&gt; in any search query like report,chart,dashboard then how it is possible?&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 10:22:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-JavaScript-code-in-Splunk-Cloud-dashboard/m-p/368500#M24070</guid>
      <dc:creator>shukan</dc:creator>
      <dc:date>2017-09-28T10:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to use JavaScript code in Splunk Cloud dashboard ?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-JavaScript-code-in-Splunk-Cloud-dashboard/m-p/368501#M24071</link>
      <description>&lt;P&gt;@shukan, While you can use &lt;CODE&gt;&amp;lt;style&amp;gt;&lt;/CODE&gt; tag directly in Splunk Simple XML dashboards to load/override CSS style, Javascript does not work this way. You will need to use &lt;CODE&gt;Simple XML JS Extension&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;There are several examples on &lt;CODE&gt;Splunk Dashboard Examples&lt;/CODE&gt; app on Splunkbase ( &lt;CODE&gt;&lt;A href="https://splunkbase.splunk.com/app/1603/" target="test_blank"&gt;https://splunkbase.splunk.com/app/1603/&lt;/A&gt;&lt;/CODE&gt; )&lt;BR /&gt;
You can also refer to Splunk Dev site for the same: &lt;A href="http://dev.splunk.com/view/SP-CAAAE4A#editjs"&gt;http://dev.splunk.com/view/SP-CAAAE4A#editjs&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Following is an example of dashboard which uses &lt;CODE&gt;hello_world.js&lt;/CODE&gt;JavaScript file.&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/3585i90D4E4478087491B/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="hello_world.js"&amp;gt;
  &amp;lt;label&amp;gt;Hello World JavaScript Example&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;div&amp;gt;
          Splunk Simple XML JavaScript Extension to show Hello World alert and console log using JavaScript file &amp;lt;b&amp;gt;hello_world.js&amp;lt;/b&amp;gt;.
          The JavaScrpt File needs to be placed under the Splunk App's Static folder i.e. &amp;lt;b&amp;gt;$SPLUNK_HOME$/apps/etc/$env:app$/appserver/static&amp;lt;/b&amp;gt;, based on the current app &amp;lt;b&amp;gt;$env:app$&amp;lt;/b&amp;gt;.
        &amp;lt;/div&amp;gt;&amp;lt;br/&amp;gt;
        &amp;lt;div&amp;gt;
          Following is the JavaScript Code:&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt; 
          &amp;lt;code&amp;gt;
            require([
                "splunkjs/mvc/simplexml/ready!"
            ], function() {
              alert("Hello World");
                console.log("Console Log: Hello World");
            });
          &amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;
          PS: Press &amp;lt;code&amp;gt;F12&amp;lt;/code&amp;gt; to Open Browser Inspect Tool to view JavaScript console log. 
        &amp;lt;/div&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is the code for JavaScript file which needs to be placed under your Splunk app's static folder:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        require([
            "splunkjs/mvc/simplexml/ready!"
        ], function() {
            alert("Hello World");
            console.log("Console Log: Hello World");
        });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: If you want to load Static files like Javascript file on Splunk Cloud you should test the same on your local Splunk Instance and then reach out to Splunk Support for getting the same uploaded to your Splunk Cloud instance.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 06:20:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-JavaScript-code-in-Splunk-Cloud-dashboard/m-p/368501#M24071</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-10-02T06:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to use JavaScript code in Splunk Cloud dashboard ?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-JavaScript-code-in-Splunk-Cloud-dashboard/m-p/620577#M50947</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Is there a way to add the java script in xml inline?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am using cloud version and don't have rights to add the script in path.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 12:02:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-JavaScript-code-in-Splunk-Cloud-dashboard/m-p/620577#M50947</guid>
      <dc:creator>biju_babu</dc:creator>
      <dc:date>2022-11-11T12:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to use JavaScript code in Splunk Cloud dashboard ?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-JavaScript-code-in-Splunk-Cloud-dashboard/m-p/627733#M51448</link>
      <description>&lt;P&gt;I'm looking for this as well, for colocation reasons. But so far I haven't found a way.&lt;/P&gt;&lt;P&gt;For people playing along at home: web.conf has a few options for dashboards (like dashboard_html_allow_embeddable_content), but seemingly nothing to allow embedding scripts.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 12:39:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-JavaScript-code-in-Splunk-Cloud-dashboard/m-p/627733#M51448</guid>
      <dc:creator>spunk_enthusias</dc:creator>
      <dc:date>2023-01-20T12:39:42Z</dc:date>
    </item>
  </channel>
</rss>

