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.
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
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
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
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.
Hi @nagar57,
please test this:
| makeresults
| eval test1="$market$", test2="$seid$", test3="$listid$"
| table test1 test2 test3
Ciao.
Giuseppe
This will run the search as the tokens are getting converted into blank string.
Hi @nagar57,
as you can see in my example it runs:
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
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.
Hi @nagar57,
in my test dashboard, also without Submit button, my search doesn't start without values:
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