<?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: Calling Java Script from Dashboard in Alerting</title>
    <link>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240268#M8985</link>
    <description>&lt;P&gt;I am using Splunk version 6.4.1.&lt;BR /&gt;
I tried this code as it is, but not worked for me.&lt;/P&gt;</description>
    <pubDate>Thu, 10 May 2018 06:34:49 GMT</pubDate>
    <dc:creator>salunkhevikram</dc:creator>
    <dc:date>2018-05-10T06:34:49Z</dc:date>
    <item>
      <title>Calling Java Script from Dashboard</title>
      <link>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240264#M8981</link>
      <description>&lt;P&gt;I am trying to call Java Script by pressing a button on Dashboard but it doesn't seem to work.&lt;BR /&gt;Could anyone teach me how to do this? As a first step, I want to pop up an alert saying "YAHOO" by clicking the button.&lt;BR /&gt;The final goal is better than that but I just want to check that JavaScript actually works.&lt;/P&gt;
&lt;P&gt;My source codes are below:&lt;/P&gt;
&lt;P&gt;Dashboard XML:&lt;BR /&gt;input type="button" name="yahoo" value="YAHOO" onClick="kakunin()"&lt;/P&gt;
&lt;P&gt;Java Script (in /opt/splunk/etc/apps//appserver/static)&lt;/P&gt;
&lt;P&gt;function kakunin(){&lt;BR /&gt;alert("YAHOO");&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jun 2020 01:11:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240264#M8981</guid>
      <dc:creator>earakam</dc:creator>
      <dc:date>2020-06-09T01:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Java Script from Dashboard</title>
      <link>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240265#M8982</link>
      <description>&lt;P&gt;Here's one way of doing it. Sample XML dashboard in app &lt;CODE&gt;custom_app&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="your_javascript_file.js"&amp;gt;
  &amp;lt;label&amp;gt;Dashboard with Javascript on Button&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;
          &amp;lt;input id="btn-submit" type="button" value="Click"/&amp;gt;
        &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;your_javascript_file.js, located in &lt;CODE&gt;custom_app/appserver/static&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    "jquery",
    "splunkjs/mvc/simplexml/ready!"
    ], function(
        $
    ) {
        $("#btn-submit").on("click", function (){
            alert("Yahoo!");
        });
    });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also, if you change the content in &lt;CODE&gt;appserver/static&lt;/CODE&gt;, you'll notice that clients who had visited the dashboard before may not download the updates of your files. This is usually due to caching, which happens both on the server and on the client. One option is to empty your client's cache (or use private mode which disables the use of existing cached objects). I'd recommend control via the server however: depending on what environment you're on, you might want to use the &lt;CODE&gt;_bump&lt;/CODE&gt; endpoint at&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;http://&amp;lt;host:mport&amp;gt;/&amp;lt;locale_string&amp;gt;/_bump
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;for a one-time reload of static assets or set &lt;CODE&gt;cacheEntriesLimit=0&lt;/CODE&gt; in web.conf to disable the cache entirely. The setting in web.conf is not something you want to do on a production server though, as it impacts performance. Refer to &lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.3/AdvancedDev/CustomizationOptions#Clear_client_and_server_assets_caches_after_customization" target="_blank"&gt;this documentation&lt;/A&gt; or &lt;A href="https://dev.splunk.com/enterprise/docs/developapps/createapps/aboutfileprecedence/#Client-and-server-asset-caching" target="_blank"&gt;this developer guide&lt;/A&gt; for more details, and also check out &lt;A href="https://dev.splunk.com/enterprise/docs/developapps/createapps/configureappproperties/#Update-static-assets-for-new-versions-of-an-app" target="_blank"&gt;this developer guide&lt;/A&gt; on how to deploy apps with updated static assets (in short, increment version and build in app.conf to automatically trigger a reload on all clients).&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:02:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240265#M8982</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2020-09-29T09:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Java Script from Dashboard</title>
      <link>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240266#M8983</link>
      <description>&lt;P&gt;oooo great!! thank you!!!&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2016 09:09:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240266#M8983</guid>
      <dc:creator>earakam</dc:creator>
      <dc:date>2016-03-14T09:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Java Script from Dashboard</title>
      <link>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240267#M8984</link>
      <description>&lt;P&gt;That helped, thanks. I also had to remove the Bootstrap divs wrapping the submit button for this to work.&lt;/P&gt;</description>
      <pubDate>Sun, 29 May 2016 20:42:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240267#M8984</guid>
      <dc:creator>rlacher1</dc:creator>
      <dc:date>2016-05-29T20:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Java Script from Dashboard</title>
      <link>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240268#M8985</link>
      <description>&lt;P&gt;I am using Splunk version 6.4.1.&lt;BR /&gt;
I tried this code as it is, but not worked for me.&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 06:34:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240268#M8985</guid>
      <dc:creator>salunkhevikram</dc:creator>
      <dc:date>2018-05-10T06:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Java Script from Dashboard</title>
      <link>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240269#M8986</link>
      <description>&lt;P&gt;You probably need to restart splunk to pick up the .js file if it's new.&lt;/P&gt;</description>
      <pubDate>Tue, 15 May 2018 05:48:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240269#M8986</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2018-05-15T05:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Java Script from Dashboard</title>
      <link>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240270#M8987</link>
      <description>&lt;P&gt;hello don't work for me also with a splunk reboot.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jun 2020 09:58:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240270#M8987</guid>
      <dc:creator>sandyBDF</dc:creator>
      <dc:date>2020-06-01T09:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Java Script from Dashboard</title>
      <link>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240271#M8988</link>
      <description>&lt;P&gt;I've updated the answer with more information. If you can't get it to work, you should ask a new question giving details what you've tried so far.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2020 12:43:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240271#M8988</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2020-06-02T12:43:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Java Script from Dashboard</title>
      <link>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240272#M8989</link>
      <description>&lt;P&gt;It's ok just i need to navigate in private mode so it's good for me sorry.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2020 12:45:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240272#M8989</guid>
      <dc:creator>sandyBDF</dc:creator>
      <dc:date>2020-06-02T12:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Java Script from Dashboard</title>
      <link>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240273#M8990</link>
      <description>&lt;P&gt;If using private mode of your browser works for you, then it's client side caching. Your browser will not download new content from the static folders if they haven't changed. I'll update the question with more info about how to handle this.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 05:39:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Calling-Java-Script-from-Dashboard/m-p/240273#M8990</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2020-06-03T05:39:33Z</dc:date>
    </item>
  </channel>
</rss>

