Dashboards & Visualizations

How to make a search box mandatory to have a value

nagar57
Communicator

I have 2 search boxes. I am using it to make to get parameters to REST API call. Now When there is no value in the search box then also the search gets executed. I want to restrict this and make it mandatory that until the user enters some value the search doesn't gets executed.

Attaching the screenshot of the problem where search is getting executed even if there are no values in the search box.

Note: I don't want to use submit button for this.

Labels (1)
Tags (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @nagar57,

if you don't put any default or initial value in the search box and you inserted the tokens in your search, the search will not be executed until you insert a value in both the search boxes.

To be more sure, you can add a Submit button, but the most important thing is the first thing: no default and initial values.

If, your search starts even if you don't put any default or initial value, please share your search.

Ciao.

Giuseppe

Tags (1)
0 Karma

nagar57
Communicator

Below is my search. The search is still getting executed when there is no value on the search box.

| makeresults 
| script ehm_ee ehm_se_suppression $market$ $seid$ $listid$ 
    [| makeresults 
    | eval uuid=random() 
    | return $uuid] 
    [| rest /services/authentication/current-context/context splunk_server=local 
    | fields email 
    | eval email=if(isnull(email) OR email=="","NA",email) 
    | return $email ] 
| eval 
    [| rest /services/authentication/current-context/context splunk_server=local 
    | fields email 
    | eval email=if(isnull(email) OR email=="","NA",email) 
    | return email ] 
| eval response = if(match(response,"Please feed"),response,response." for "."$market$"." market for SE ID: "."$seid$"." and List ID: "."$listid$".". Results will be sent to your email id: ".email)
| table response
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @nagar57,

did you checked if there's a default or initial value for the text inputs?

try to replace your search with a simpler test search:

| makeresults 
| eval test1=$market$, test2=$seid$, test3=$listid$ 
| table test1 test2 test3

is it executed?

Ciao.

Giuseppe

0 Karma

nagar57
Communicator

There are no default or initial values configured.
After testing your solution I am getting below message
Error in 'eval' command: The expression is malformed. An unexpected character is reached at ', list_id=, market=jp'.

This message will be inappropriate for the user.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @nagar57,

please test this:

| makeresults 
| eval test1="$market$", test2="$seid$", test3="$listid$" 
| table test1 test2 test3

Ciao.

Giuseppe

0 Karma

nagar57
Communicator

This will run the search as the tokens are getting converted into blank string. 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @nagar57,

as you can see in my example it runs:

gcusello_0-1630922426241.png

please, try to put the Submit button, then load another dashboard and then come back to this dashboard: I experienced a cache problem if I inser a value one time in the search box.

Ciao.

Giuseppe

0 Karma

nagar57
Communicator

I can't use Submit button as I have to replicate this panel in the same dashboard. And for that Splunk doesn't provide the functionality of using multiple Submit buttons.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @nagar57,

in my test dashboard, also without Submit button, my search doesn't start without values:

gcusello_0-1630924151778.png

Please try to open another dashboard and run your dashboard:

As I said, first time I open the dahboard the search doesn't start, if I insert a value, it starts.

If you have the same situation, it's possible to insert an in put to reset tokes:

    <input type="radio" token="resetTokens" searchWhenChanged="true">
      <label></label>
      <choice value="reset">Reset Inputs</choice>
      <choice value="retain">Retain</choice>
      <default>retain</default>
      <change>
        <condition value="reset">
          <unset token="your_token"></unset>
          <set token="resetTokens">retain</set>
        </condition>
      </change>
    </input>

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...