Dashboards & Visualizations

Passing (or global) variables between forms/nav with simple xml

ralphmct
Path Finder

My "welcome" form has an ID that I've made a dropdown box for to choose - loaded from a search of my custom IDs from my data input source.

When I move to other dashboards/forms, I want my charts to take into account the ID I've chosen in the "welcome" form. Is there a way to do this using simple XML? I'm aware that it's possible with advanced XML and easier again using sideview utils but I'm trying to stay within simple XML for various reasons I'll not go into here.

As a side note, I want all the dashboards/forms to have the same dropdown box available and to automatically pre-load the ID each time with the one I chose on the "welcome" page (or to update if I choose a new one).

I've tried passing the variable via URL using a drilldown but the problem with that is that I want the user to be free to navigate wherever they want and the ID to pass successfully each time.

I also considering having something embedded in the default.xml, maybe a javascript global variable or something, but it seems like I'd need to move to advanced XML for that.

The last thing I considered was to make a custom command (using commands.conf) which calls a python script to store the ID and a different one on load of the form that gets the ID but that has its problems also; I'd need a default search and onclick search for the dropdown!

Does anyone have any other workaround? Again, I want to stay with simple XML. I could move to advanced XML down the line but I'd really prefer a simple XML solution in the first instance.

Thanks for any help!

0 Karma
1 Solution

gkanapathy
Splunk Employee
Splunk Employee

It certainly should be possible to do this client side in JS. I don't know how much you've looked at the Simple XML enhancements in version 6.0, but you can embed any JS and CSS file into your SXML. (You can also specify ids and classes for your SXML objects now.)

You can use this to set the user id on the welcome page, then retrieve it via JS on the other pages.

If you download and install the Splunk 6 Dashboard Examples app, you'll see something close you what you want (not exactly, because it pulls the values from an SDK call rather than your own variable, so you'll have to provide your own "set" and "get" mechanism, which shouldn't be hard) in this dashboard http://10.160.203.74:8000/en-US/app/simple_xml_examples/custom_app_token

View solution in original post

gkanapathy
Splunk Employee
Splunk Employee

It certainly should be possible to do this client side in JS. I don't know how much you've looked at the Simple XML enhancements in version 6.0, but you can embed any JS and CSS file into your SXML. (You can also specify ids and classes for your SXML objects now.)

You can use this to set the user id on the welcome page, then retrieve it via JS on the other pages.

If you download and install the Splunk 6 Dashboard Examples app, you'll see something close you what you want (not exactly, because it pulls the values from an SDK call rather than your own variable, so you'll have to provide your own "set" and "get" mechanism, which shouldn't be hard) in this dashboard http://10.160.203.74:8000/en-US/app/simple_xml_examples/custom_app_token

gkanapathy
Splunk Employee
Splunk Employee

Yes, unfortunately. Your best best might be to use a jquery plugin for session storage and include that in the relevant dashboards.

0 Karma

ralphmct
Path Finder

I've abandoned this for now because the get/set wasn't as straightforward in JS as I'd hoped; there wasn't an easy way of setting/passing a variable without running into limitations. Accepting the answer though because the Splunk 6 examples app was very helpful and embedding Javascript was as described

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...