Dashboards & Visualizations

Edit XML disables Javascript?

Cardonymous
Explorer

Hello,

 

I added some Javascript functionality to my multi selections (see: https://www.advisori.de/splunk-struggles-with-multiselects-and-how-to-rule-them-all-or-at-least-some...).
The script works totally fine and works for my dashboard, until I edit the XML. 

If I click edit, change some code and click either save or discard, the multi selections behave as if the script would not exist. That means the automatic option removal is not working at all anymore. 
Clearing the cache locally in my browser or using the _bump endpoint solves the problem and makes the dashboard and the script work fine again -  just until the XML is edited again.

Is there a better (permanent) solution except for clearing the cache after each edit?
Thanks in advance!

Labels (2)
0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

@Cardonymous 

In any dashboard with Javascript Extensions, when you edit the XML it will not impact immediately after saving . You need to reload the dashboard again to get javascript executed. So when you edit the dashboard XML and save it , you need to reload dashboard. 

If you had selected the inputs values during edit OR before edit, that values might impact the behaviour of dashboard. But it is only the time of saving XML. Again after reloading the dashboard it will work as expected.

Please try it and let me know.

 

 

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Depending on what you are trying to do with the JS, you may be able to do it in SimpleXML, then you don't have to worry about JS caching. 😀

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@Cardonymous 

In any dashboard with Javascript Extensions, when you edit the XML it will not impact immediately after saving . You need to reload the dashboard again to get javascript executed. So when you edit the dashboard XML and save it , you need to reload dashboard. 

If you had selected the inputs values during edit OR before edit, that values might impact the behaviour of dashboard. But it is only the time of saving XML. Again after reloading the dashboard it will work as expected.

Please try it and let me know.

 

 

0 Karma

Cardonymous
Explorer

@kamlesh_vaghela 

Oh yes indeed, you are right. That works for me, thanks a lot!

So JavaScript will only be executed when initially loading the dashboard?

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

Yes, Javascript will be load during the initialisation of supporting javascript which will happen on fresh load of dashboard.

🙂 

Cardonymous
Explorer

Thanks a lot for your explanation 😊

0 Karma
Get Updates on the Splunk Community!

New Splunk Observability innovations: Deeper visibility and smarter alerting to ...

You asked, we delivered. Splunk Observability Cloud has several new innovations giving you deeper visibility ...

Synthetic Monitoring: Not your Grandma’s Polyester! Tech Talk: DevOps Edition

Register today and join TekStream on Tuesday, February 28 at 11am PT/2pm ET for a demonstration of Splunk ...

Instrumenting Java Websocket Messaging

Instrumenting Java Websocket MessagingThis article is a code-based discussion of passing OpenTelemetry trace ...