Dashboards & Visualizations

Help with Conditions for Change on checkbox control in SimpleXML

Path Finder

Hopefully I can explain this in a clear way. I am going to post the pictures below, so please take a look at them, as they will be necessary to understand my question.

The way I have my dashboard set up is that the Split-Shift View checkbox is only be valid if the Today or Yesterday radio button is selected. Whenever This Hour, This Week, or This Year is selected, it deselects/clears the Split-Shift View checkbox. This all works fine.

I need to code the flip-side. I would like to make it so that if any thing other than Today or Yesterday is selected when the Split-Shift View box is selected, it automatically selects the Today radio button. We have tried just about everything to make this work and the main problem is that it appears that the change stuff is broken for checkbox field controls because it always hits the first condition.
alt text

alt text

Splunk Employee
Splunk Employee

hi @noah_woodcock,

Did one of the answers below solve your problem? If so, please resolve this post by approving it!

If your problem is still not solved, keep us updated so that someone else can help ya.

Thanks for posting!

0 Karma

SplunkTrust
SplunkTrust

Hi @Noah_Woodcock,

If you are not using multiple values in checkbox, below should work,

EDIT : Added suggestion from @niketnilay

<form>
  <fieldset submitButton="false">
    <input type="radio" token="timespan" searchWhenChanged="true">
      <label>Timespan</label>
      <choice value="hour">This hour</choice>
      <choice value="today">Today</choice>
      <choice value="yesterday">Yesterday</choice>
      <choice value="thisweek">This week</choice>
      <change>
        <condition value="today">
          <set token="form.split">on</set>
        </condition>
        <condition value="yesterday">
          <set token="form.split">on</set>
        </condition>        
        <condition>
          <unset token="form.split"></unset>
          <unset token="split"></unset>
        </condition>
      </change>      
    </input>
    <input type="checkbox" token="split">
      <label>Panel View Options</label>
      <choice value="on">Split-Shift View</choice>
        <change>
          <condition match="$split$==&quot;on&quot; AND ($timespan$==&quot;hour&quot; OR $timespan$==&quot;thisweek&quot;)">
            <set token="form.timespan">today</set>
          </condition>
        </change>
    </input>
  </fieldset>
  <row>
    <html>
      <h2>Selected Time Span : $timespan$</h2>
    </html>
  </row>
</form>

Legend

@renjith.nair, slight correction. The Split Check box is supposed to be checked even when Yesterday is selected. Which means if Yesterdays is selected and if check box is checked at that time, then Time span will change to Today. Following should be used instead:

<form>
  <label>Linked Radio and Checkbox</label>
   <fieldset submitButton="false">
     <input type="radio" token="timespan" searchWhenChanged="true">
       <label>Timespan</label>
       <choice value="hour">This hour</choice>
       <choice value="today">Today</choice>
       <choice value="yesterday">Yesterday</choice>
       <choice value="thisweek">This week</choice>
       <change>
         <condition value="today">
           <set token="form.split">on</set>
         </condition>
         <condition value="yesterday">
           <set token="form.split">on</set>
         </condition>
         <condition>
           <unset token="form.split"></unset>
         </condition>
       </change>      
     </input>
     <input type="checkbox" token="split">
       <label>Panel View Options</label>
       <choice value="on">Split-Shift View</choice>
       <change>
         <condition match="$split$==&quot;on&quot; AND ($timespan$==&quot;hour&quot; OR $timespan$==&quot;thisweek&quot;)">
           <set token="form.timespan">today</set>
         </condition>
       </change>
     </input>
   </fieldset>
   <row>
     <html>
       <div>Selected Time Span : $timespan$</div>
       <div>Split: $split$</div>
     </html>
   </row>
 </form>

PS: I have added the following to your code:

1)

      <condition value="yesterday">
        <set token="form.split">on</set>
      </condition>

2)

       <change>
         <condition match="$split$==&quot;on&quot; AND ($timespan$==&quot;hour&quot; OR $timespan$==&quot;thisweek&quot;)">
           <set token="form.timespan">today</set>
         </condition>
       </change>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

SplunkTrust
SplunkTrust

Thanks @niketnilay. Missed yesterday 🙂

State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!