Dashboards & Visualizations

How to make submit button run search without change in input?

matstap
Communicator

I'm trying to make a submit button that always performs a search. Right now it only runs if there is a change in input values.

Is there a way to make the submit button run the search without having to change input values?

0 Karma
1 Solution

493669
Super Champion

You can try to refresh your panel query at specific interval:

<refresh>5m</refresh>

applicable for Splunk Enterprise 6.5 onward.
else try:

<option name="refresh.auto.interval">300</option>

OR
I have created sample dashboard for you with use of js.
try below code:
mydashboard.xml :

<form script="my.js">
:::
</form>

my.js :

require([
     'underscore',
     'jquery',
     'splunkjs/mvc',
     'splunkjs/mvc/tableview',
     'splunkjs/mvc/simplexml/ready!'
 ], function(_, $, mvc, TableView) {
$("#btn-submit").on("click",function (){
var mySearch=splunkjs.mvc.Components.getInstance(search1);
mySearch.startSearch();
});
});

Give your dashboard search id="search1"
here on click of submit button it will run the search

View solution in original post

493669
Super Champion

You can try to refresh your panel query at specific interval:

<refresh>5m</refresh>

applicable for Splunk Enterprise 6.5 onward.
else try:

<option name="refresh.auto.interval">300</option>

OR
I have created sample dashboard for you with use of js.
try below code:
mydashboard.xml :

<form script="my.js">
:::
</form>

my.js :

require([
     'underscore',
     'jquery',
     'splunkjs/mvc',
     'splunkjs/mvc/tableview',
     'splunkjs/mvc/simplexml/ready!'
 ], function(_, $, mvc, TableView) {
$("#btn-submit").on("click",function (){
var mySearch=splunkjs.mvc.Components.getInstance(search1);
mySearch.startSearch();
});
});

Give your dashboard search id="search1"
here on click of submit button it will run the search

493669
Super Champion

Hi @matstap,
have you tried this?
if it helps you then accept the answer and do up vote .
Thanks.

0 Karma

ashishamalviya1
Explorer

can you please share my.js code as a test example, with some search query,

    <row>
    <panel>
      <search id="bulkSearch">
        <query>
        | inputlookup flowmkts_lookuptable | WHERE NOT hostname="$field3$" OR eventtype="$field4$" | outputlookup flowmkts_lookuptable
        </query>
      </search>
      <html>
            <button id="deletebutton">Delete</button>
      </html>
    </panel>
  </row>
0 Karma

niketn
Legend

@ashishamalviya1 is your requirement to perform search on Button click? Based on your Simple XML dashboard code seems like you want to perform a Delete operation. If so, please post a new question with your requirement details as this question is for executing Search on click of button for which the JS code also has been attached.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Get Updates on the Splunk Community!

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 ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...