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!

Splunk Decoded: Service Maps vs Service Analyzer Tree View vs Flow Maps

It’s Monday morning, and your phone is buzzing with alert escalations – your customer-facing portal is running ...

What’s New in Splunk Observability – September 2025

What's NewWe are excited to announce the latest enhancements to Splunk Observability, designed to help ITOps ...

Fun with Regular Expression - multiples of nine

Fun with Regular Expression - multiples of nineThis challenge was first posted on Slack #regex channel ...