Dashboards & Visualizations

How do I import an external script in advanced xml?

dlee360
Explorer

I know in simple xml, you can add a script="xx.js" in the dashboard tag, but how do I add an external script in advanced xml?

Thanks!
David

0 Karma

paramagurukarth
Builder

Inside application.js.... (http://docs.splunk.com/Documentation/Splunk/6.2.1/Module/Simplecustomizations)
After checking your current view name... you can do it using jquery
Below code is to include a css file
(You can place your js file into ../appserver/static of your application)

 switch (Splunk.util.getCurrentView()) {
       case "simple_alert_list_new":
             jQuery("<link rel=\"stylesheet\" type=\"text/css\" href=\"/static/css/bootstrap.min.css\"/>").appendTo("head");
0 Karma

dlee360
Explorer

Thanks, but I don't have access to add to the /appserver/static directory. Maybe I'm overthinking this. I'm trying to use bootstrap modal and it works in simple xml. I just can't get it to work using advanced xml. I was thinking that maybe it was because the calling of the modal.js script. That's my best guess.
http://blogs.splunk.com/2014/02/24/using-bootstrap-modal-with-splunk-simple-xml/

0 Karma

paramagurukarth
Builder

If you don't have rights to create appserver/static directory.. you can use the bootstrap.js available inside splunk.. All the resources present inside "exposed" (ie, C:\Program Files\Splunk\share\splunk\search_mrsparkle\exposed)
are exposed in splunk as static resouces...
Url Patter to refer this is :
http://localhost:8000/en-GB/static/js/contrib/jquery/jquery.js
ie,


And you can inject the HTML code for the model using jquery or pure JavaScript by adding few line in application.js...

But, Make sure you are appending the script file after including the ...
Above is just up to my knowledge.. There may be some other options too...

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...