Dashboards & Visualizations

Why a custom Java Script message appearing in each load?

ASorathiya1986
Loves-to-Learn Everything

 

I am using custom js from dashboard ui.xml

 

 

 

 

<form version="1.1" stylesheet="vulnerability_center.css" script="multiselect_input.js">

 

 

 

 

you can find my js file

 

 

 

 

 

require([
    'splunkjs/mvc',
    'splunkjs/mvc/simplexml/ready!'
    ],
    function(_,mvc){

        function setupMultiInput(instance_id) {

        var multiselect = mvc.Components.get(instance_id);
	    const without = (array, filtered) => array.filter(n => n != filtered);

            if (multiselect){
                multiselect.on("change", function(){
                    let current_val = multiselect.val();
                    let first_choice_value = multiselect.options.choices[0].value;
                    if (current_val.length > 1 && current_val.indexOf(first_choice_value) == 0) {
                        multiselect.val(without(current_val, first_choice_value));
                    }
                    if (current_val.length > 1 && current_val.includes(first_choice_value) && current_val.indexOf(first_choice_value) != 0) {
                        multiselect.val([first_choice_value]);
                    }
                });
            }
        };

        var all_multi_selects = document.getElementsByClassName("input-multiselect");
        for (let j = 0; j < all_multi_selects.length; j++) {
            setupMultiInput(all_multi_selects[j].id);
        }
    }
)

 

 

 

 

 

 

Labels (2)
Tags (3)
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@ASorathiya1986 

Can you please share your sample XML as well?

KV

0 Karma

ASorathiya1986
Loves-to-Learn Everything

@kamlesh_vaghela any suggestions here?

 

0 Karma
Get Updates on the Splunk Community!

Prove Your Splunk Prowess at .conf25—No Prereqs Required!

Your Next Big Security Credential: No Prerequisites Needed We know you’ve got the skills, and now, earning the ...

Splunk Observability Cloud's AI Assistant in Action Series: Observability as Code

This is the sixth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Splunk Answers Content Calendar, July Edition I

Hello Community! Welcome to another month of Community Content Calendar series! For the month of July, we will ...