<?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 Loading JavaScript in Custom Alert Action HTML File in Splunk? in Alerting</title>
    <link>https://community.splunk.com/t5/Alerting/Loading-JavaScript-in-Custom-Alert-Action-HTML-File-in-Splunk/m-p/693738#M16137</link>
    <description>&lt;P&gt;Hello everyone! I've created a &lt;STRONG&gt;custom alert action&lt;/STRONG&gt; with an HTML file located at &lt;STRONG&gt;Splunk\etc\apps\my-app\local\data\ui\alerts\index.html&lt;/STRONG&gt;, and my JavaScript and CSS files are in &lt;STRONG&gt;Splunk\etc\apps\my-app\appserver\static\index.js&lt;/STRONG&gt;. My goal is to dynamically add fields to a form using JavaScript inside my HTML file. I'm encountering challenges with loading the JavaScript due to potential security concerns in Splunk apps. Despite this, I'm looking for a solution to implement this small functionality. Any assistance would be greatly appreciated.&lt;BR /&gt;Thank you for your help!&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;HTML code -&amp;nbsp;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;title&amp;gt;Custom Alert Action&amp;lt;/title&amp;gt;
&amp;lt;script&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="../../../../appserver/static/index.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;h1&amp;gt;Custom Alert Action&amp;lt;/h1&amp;gt;
&amp;lt;button id="performActionBtn"&amp;gt;Perform Action&amp;lt;/button&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;JS code -&lt;/STRONG&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;require([
    'jquery',
     'splunkjs/mvc',
     'splunkjs/mvc/simplexml/ready!'
], function($, mvc) {

console.log('js loaded successfully');
    function createfunction() {
        alert('js loaded successfully!');
    }
    $(document).ready(function() {
console.log('js loaded successfully');
        $('#performActionBtn').click(function(event) {
            event.preventDefault(); 
            createfunction(); 
        });
    });
});&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;hi dear&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/128473"&gt;@avikramengg&lt;/a&gt;, I saw a similar question you asked earlier. Have you found a solution? If so, could you please advise me as well? Thanks!&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jul 2024 14:18:11 GMT</pubDate>
    <dc:creator>rick-exp54</dc:creator>
    <dc:date>2024-07-18T14:18:11Z</dc:date>
    <item>
      <title>Loading JavaScript in Custom Alert Action HTML File in Splunk?</title>
      <link>https://community.splunk.com/t5/Alerting/Loading-JavaScript-in-Custom-Alert-Action-HTML-File-in-Splunk/m-p/693738#M16137</link>
      <description>&lt;P&gt;Hello everyone! I've created a &lt;STRONG&gt;custom alert action&lt;/STRONG&gt; with an HTML file located at &lt;STRONG&gt;Splunk\etc\apps\my-app\local\data\ui\alerts\index.html&lt;/STRONG&gt;, and my JavaScript and CSS files are in &lt;STRONG&gt;Splunk\etc\apps\my-app\appserver\static\index.js&lt;/STRONG&gt;. My goal is to dynamically add fields to a form using JavaScript inside my HTML file. I'm encountering challenges with loading the JavaScript due to potential security concerns in Splunk apps. Despite this, I'm looking for a solution to implement this small functionality. Any assistance would be greatly appreciated.&lt;BR /&gt;Thank you for your help!&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;HTML code -&amp;nbsp;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;title&amp;gt;Custom Alert Action&amp;lt;/title&amp;gt;
&amp;lt;script&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="../../../../appserver/static/index.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;h1&amp;gt;Custom Alert Action&amp;lt;/h1&amp;gt;
&amp;lt;button id="performActionBtn"&amp;gt;Perform Action&amp;lt;/button&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;JS code -&lt;/STRONG&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;require([
    'jquery',
     'splunkjs/mvc',
     'splunkjs/mvc/simplexml/ready!'
], function($, mvc) {

console.log('js loaded successfully');
    function createfunction() {
        alert('js loaded successfully!');
    }
    $(document).ready(function() {
console.log('js loaded successfully');
        $('#performActionBtn').click(function(event) {
            event.preventDefault(); 
            createfunction(); 
        });
    });
});&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;hi dear&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/128473"&gt;@avikramengg&lt;/a&gt;, I saw a similar question you asked earlier. Have you found a solution? If so, could you please advise me as well? Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 14:18:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Loading-JavaScript-in-Custom-Alert-Action-HTML-File-in-Splunk/m-p/693738#M16137</guid>
      <dc:creator>rick-exp54</dc:creator>
      <dc:date>2024-07-18T14:18:11Z</dc:date>
    </item>
  </channel>
</rss>

