Dashboards & Visualizations
Highlighted

Search a yes/no field with a single checkbox token

Contributor

Dear All,

I have a YES/NO field named "FIELD2" which I want to search with a single checkbox token named "Checkbox1" , in the following way:

Checkbox1.checked = TRUE   
search:  index=db FIELD1= FIELD2="YES"

Checkbox2.checked = FALSE  
search:  index=db FIELD1= FIELD2="*"
or better
search:  index=db FIELD1=

I tried with condition and match but no result.

Can someone advise "from scratch"?

best regards
Altin

Tags (2)
0 Karma
Highlighted

Re: Search a yes/no field with a single checkbox token

Influencer

Hi,
Try with these conditions for checkbox,

YES
NO

Also in your search use FIELD=$checkbox_tokenname$

0 Karma
Highlighted

Re: Search a yes/no field with a single checkbox token

Contributor

Thank you very much for the reply.

to explain better,
below is the code of my checkbox:

<input type="checkbox" token="checkbox1" searchWhenChanged="true">
      <label>toggle</label>
      <choice value="YES">On</choice>
      <change>
        <condition match="$checkbox1$==&quot;YES&quot;">
          <set token="token2">"YES"</set>
        </condition>
        <condition>
          <set token="token2">"*"</set>
        </condition>
      </change>
    </input>

and the search is like

index=.... FIELD2= $token2$

Initially when it opens, the search is made with FIELD2= "*".
When I first check the checkbox - id does not search. Or better said - it is searching the same (all), thus no movement in the page.
Checking and unchecking later will work - but in the opposite expected result.
When Checked - all results YES/NO come out - I was expecting only YES.
When unchecking - only the YES come out - I was expecting both.

best regards
Altin

0 Karma
Highlighted

Re: Search a yes/no field with a single checkbox token

Influencer

Instead of using condition tags, you can use below if it helps

On

and the token for checkbox i.e. checkbox1 can be used in search like
index=.... FIELD2= "$checkbox1$"

Please check if it needs to be in quotes or not, see the value of checkbox token in URL when dashboard loads.

0 Karma
Highlighted

Re: Search a yes/no field with a single checkbox token

Contributor

I have tried that (using the same chekbox-es token), but it doesn't work.

regards
Altin

0 Karma
Highlighted

Re: Search a yes/no field with a single checkbox token

Contributor

I have done what I need with a Dropdown as below:

<input type="dropdown" token="field2">
      <label>Effective User</label>
      <default>*</default>
      <prefix>"</prefix>
      <suffix>"</suffix>
      <choice value="YES">On</choice>
      <choice value="*">Off</choice>
    </input>

and the search is:

... | search ......... CURR_USER=$field2$

What I need is to to the same, but with a Checkbox, not a Dropdown

best regards
Altin

0 Karma
Highlighted

Re: Search a yes/no field with a single checkbox token

Influencer

Hi,

I was able to do with the checkbox, similar code to what you have done. See the code below, it works fine for me.

<input type="checkbox" token="checkbox1" searchWhenChanged="true">
  <label></label>
  <choice value="YES">On</choice>
  <change>
    <condition match="$checkbox1$==&quot;YES&quot;">
      <eval token="token2">"YES"</eval>
      <!--<unset token="checkbox1"></unset>-->
    </condition>
    <condition>
      <eval token="token2">"*"</eval>
    </condition>
  </change>
  <delimiter> </delimiter>
  <default>YES</default>
  <initialValue>YES</initialValue>
</input>
0 Karma
Highlighted

Re: Search a yes/no field with a single checkbox token

Contributor

It works in the opposite, not the way I am looking for.
Checked - shows All
Unchecked - shows only YES

best regards
Altin

0 Karma
Highlighted

Re: Search a yes/no field with a single checkbox token

Influencer

Hi,
This is happening only when dashboard is initially loaded, once you click on the checkbox the token sets appropriately.
I removed the default and initiaValue options for my checkbox, and now on refreshing the dashboard the initial value of checkbox is unchecked and token value is *, on checking the box the token value is changing to Yes and again on unchecking to * which is as expected.
It works perfect for me.

Thanks
Vijeta

0 Karma
Highlighted

Re: Search a yes/no field with a single checkbox token

Contributor

thank you very much for following this.

but I have the same result (opposite behavior), even after removing lines as suggested

<input type="checkbox" token="checkbox1" searchWhenChanged="true">
   <label></label>
   <choice value="YES">On</choice>
   <change>
     <condition match="$checkbox1$==&quot;YES&quot;">
       <eval token="token2">"YES"</eval>
       <!--<unset token="checkbox1"></unset>-->
     </condition>
     <condition>
       <eval token="token2">"*"</eval>
     </condition>
   </change>
   <delimiter> </delimiter>
 </input>

best regards
Altin

0 Karma