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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...