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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...