Dashboards & Visualizations

How can I set my single/boolean checkbox value from the results of a search?

woodcock
Esteemed Legend

I am saving a boolean 0 or 1 value inside of a lookup file and I'd like to read this value and change the status of my checkbox input accordingly. I though that this would be easy or at least documented but it is neither...

Here is the essence of my dashboard:

<dashboard>
  <label>GREGG TEST CHECKBOX: https://answers.splunk.com/answers/790052/</label>;
  <search id="mybasesearch">
    <query>| makeresults | eval my_boolean = "1"</query>
    <done>
      <condition match="$result.my_boolean$==1">
        <set token="my_boolean_checkbox"></set>
        <set token="form.my_boolean_checkbox">1</set>
      </condition>
      <condition>
        <unset token="my_boolean_checkbox"></unset>
        <unset token="form.my_boolean_checkbox"></unset>
      </condition>
    </done>
    <earliest>-1s</earliest>
    <latest>now</latest>
  </search>
  <fieldset submitButton="true" autoRun="false">
    <input type="checkbox" token="my_boolean_checkbox">
      <label>Do something?</label>
      <choice value="1">Checked means "yes"</choice>
      <change>
        <condition value="1">
          <eval token="my_boolean">"1"</eval>
        </condition>
        <condition>
          <eval token="my_boolean">"0"</eval>
        </condition>
      </change>
    </input>
  </fieldset>
</dashboard>
0 Karma
1 Solution

vnravikumar
Champion

Hi @woodcock

Please check this

<form>
  <label>GREGG TEST CHECKBOX: https://answers.splunk.com/answers/790052/</label>;
  <search id="mybasesearch">
    <query>| makeresults | eval my_boolean = "1"</query>
    <done>
      <condition match="$result.my_boolean$==&quot;1&quot;">
        <set token="form.my_boolean_checkbox">1</set>
      </condition>
      <condition>
        <unset token="form.my_boolean_checkbox"></unset>
      </condition>
    </done>
    <earliest>-1s</earliest>
    <latest>now</latest>
  </search>
  <fieldset submitButton="true" autoRun="false">
    <input type="checkbox" token="my_boolean_checkbox">
      <label>Do something?</label>
      <choice value="1">Checked means "yes"</choice>
      <change>
        <condition value="1">
          <eval token="my_boolean">"1"</eval>
        </condition>
        <condition>
          <eval token="my_boolean">"0"</eval>
        </condition>
      </change>
      <delimiter> </delimiter>
    </input>
  </fieldset>
</form>

View solution in original post

0 Karma

vnravikumar
Champion

Hi @woodcock

Please check this

<form>
  <label>GREGG TEST CHECKBOX: https://answers.splunk.com/answers/790052/</label>;
  <search id="mybasesearch">
    <query>| makeresults | eval my_boolean = "1"</query>
    <done>
      <condition match="$result.my_boolean$==&quot;1&quot;">
        <set token="form.my_boolean_checkbox">1</set>
      </condition>
      <condition>
        <unset token="form.my_boolean_checkbox"></unset>
      </condition>
    </done>
    <earliest>-1s</earliest>
    <latest>now</latest>
  </search>
  <fieldset submitButton="true" autoRun="false">
    <input type="checkbox" token="my_boolean_checkbox">
      <label>Do something?</label>
      <choice value="1">Checked means "yes"</choice>
      <change>
        <condition value="1">
          <eval token="my_boolean">"1"</eval>
        </condition>
        <condition>
          <eval token="my_boolean">"0"</eval>
        </condition>
      </change>
      <delimiter> </delimiter>
    </input>
  </fieldset>
</form>
0 Karma

woodcock
Esteemed Legend

IT WORKS! THANK YOU!!!!

0 Karma

vnravikumar
Champion

Welcome 🙂

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