Getting Data In

How to control the default in a dropdown menu

HattrickNZ
Motivator

I have the following dropdown menu:

  <fieldset autoRun="true" submitButton="false">
    <input type="dropdown" token="select_wday">
      <label>Select Day:</label>
      <choice value="Mon">Mon</choice>
      <choice value="Tue">Tue</choice>
      <choice value="Wed">Wed</choice>
      <choice value="Thu">Thu</choice>
      <choice value="Fri">Fri</choice>
      <choice value="Sat">Sat</choice>
      <choice value="Sun">Sun</choice>
      <default>Fri</default>
    </input>
  </fieldset>

The default in the drop-down above would be Friday. Is there a way I could control it that if the user visited the dashboard on a Wednesday the would Wednesday as the value in the drop-down menu?

I am thinking something liket the below which I have used to populate a checkbox, but I have not used it to set the default.

           <populatingSearch fieldForValue="userLabel" fieldForLabel="userLabel" earliest="-24h" latest="now">
        <![CDATA[
<search goes here that would give the current day of the week>
        ]]>
      </populatingSearch>
0 Karma
1 Solution

PowerPacked
Builder

Hi @HattrickNZ

give this a try

<dashboard>
  <label>check123</label>
      <search>
      <query>|makeresults  | eval Date=strftime(_time," %a") | table Date</query>
          <earliest>-15m</earliest>
          <latest>now</latest>
          <finalized >
                     <condition match=" 'job.resultCount' != 0">
                             <set token="Date">$result.Date$</set>
                      </condition>
           </finalized >           
    </search>
     <fieldset autoRun="true" submitButton="false">
     <input type="dropdown" token="select_wday">
       <label>Select Day:</label>
       <choice value="Mon">Mon</choice>
       <choice value="Tue">Tue</choice>
       <choice value="Wed">Wed</choice>
       <choice value="Thu">Thu</choice>
       <choice value="Fri">Fri</choice>
       <choice value="Sat">Sat</choice>
       <choice value="Sun">Sun</choice>
       <default>$Date$</default>
     </input>
   </fieldset>
</dashboard>

Thanks

View solution in original post

PowerPacked
Builder

Hi @HattrickNZ

give this a try

<dashboard>
  <label>check123</label>
      <search>
      <query>|makeresults  | eval Date=strftime(_time," %a") | table Date</query>
          <earliest>-15m</earliest>
          <latest>now</latest>
          <finalized >
                     <condition match=" 'job.resultCount' != 0">
                             <set token="Date">$result.Date$</set>
                      </condition>
           </finalized >           
    </search>
     <fieldset autoRun="true" submitButton="false">
     <input type="dropdown" token="select_wday">
       <label>Select Day:</label>
       <choice value="Mon">Mon</choice>
       <choice value="Tue">Tue</choice>
       <choice value="Wed">Wed</choice>
       <choice value="Thu">Thu</choice>
       <choice value="Fri">Fri</choice>
       <choice value="Sat">Sat</choice>
       <choice value="Sun">Sun</choice>
       <default>$Date$</default>
     </input>
   </fieldset>
</dashboard>

Thanks

HattrickNZ
Motivator

that's kind of it.

but it is putting a space(%20) before the Fri

for example the url goes to this
/check123?form.select_wday=%20Fri

and if I wanna pass the select_wday to other panels further down it puts the space in front of Fri.
Any way to not add the space?
tks

0 Karma

PowerPacked
Builder

extra space was added in | eval Date=strftime(_time," %a")

try taking out the space as this ---- | eval Date=strftime(_time,"%a")

Thanks

HattrickNZ
Motivator

tks missed that!

0 Karma

pradeepkumarg
Influencer
|makeresults  | eval Date=strftime(_time," %a") | table Date

pradeepkumarg
Influencer

This will give you the complete list with first option as Today's

|makeresults  | eval Date=strftime(_time," %a") | table Date
| append [|gentimes start=10/28/07 | head 7 | eval Date=strftime(endtime," %a") | table Date] | dedup Date

HattrickNZ
Motivator

tks, my question was more around the xml part. how should the xml code look?

0 Karma
Get Updates on the Splunk Community!

Observability Unlocked: Kubernetes Monitoring with Splunk Observability Cloud

  Ready to master Kubernetes and cloud monitoring like the pros?Join Splunk’s Growth Engineering team for an ...

Wrapping Up Cybersecurity Awareness Month

October might be wrapping up, but for Splunk Education, cybersecurity awareness never goes out of season. ...

🌟 From Audit Chaos to Clarity: Welcoming Audit Trail v2

&#x1f5e3; You Spoke, We Listened  Audit Trail v2 wasn’t written in isolation—it was shaped by your voices.  In ...