Dashboards & Visualizations
Highlighted

selectFirstChoice not working in dynamic dropdowns after update of generating search

Communicator

Hi guys

I have three form inputs. The last two are dynamic dropdowns. Their values are generated with a search, in which the value from the first input is used. The dropdowns are configured to always select the first choice

<selectFirstChoice>true</selectFirstChoice>

Whenever I change the first input, the two other dynamic dropdowns are regenerated. Unfortunately the dropdown's selected choice goes empty, instead of choosing the first available value.

Has someone else experienced the same? Or can someone provide me with a workaround?
Thank you

Highlighted

Re: selectFirstChoice not working in dynamic dropdowns after update of generating search

Path Finder

I see the same issue. When I update a dropdown menu, the ones that depend on it and use the selectFirstChoice flag will update their contents, but not change the actual parameter.

E.g.,
Menu contains {0,5,10}, selects '0'. After updating another menu, it now contains {5, 10, 15}, but still sits on '0'.

This makes the feature somewhat useless.

Highlighted

Re: selectFirstChoice not working in dynamic dropdowns after update of generating search

SplunkTrust
SplunkTrust

I guess that works just on the first load of the dashboard. If the underlying data source for the dropdown is changed some how, it's ignoring the updated first value.

0 Karma
Highlighted

Re: selectFirstChoice not working in dynamic dropdowns after update of generating search

Explorer
0 Karma
Highlighted

Re: selectFirstChoice not working in dynamic dropdowns after update of generating search

Communicator

Converting to HTML is no option for us. Our users then would not be possible to make any further changes to the dashboard. I am sorry, but that is no solution for us.

0 Karma
Highlighted

Re: selectFirstChoice not working in dynamic dropdowns after update of generating search

Splunk Employee
Splunk Employee

You can set this for the dropdown:

<change>
    <unset token="form.dropdown"></unset>
</change>

example dashboard

<form script="simple_xml_examples:showtokens.js"> 
  <label>selectfirstchoice</label> 
  <fieldset submitButton="false" autoRun="true"> 
    <input type="dropdown" token="dropdown" searchWhenChanged="true"> 
      <!--<choice value="foo">Foo</choice>--> 
      <search> 
        <query>index=$index$ | head 200 | stats count by sourcetype</query> 
      </search> 
      <fieldForLabel>sourcetype</fieldForLabel> 
      <fieldForValue>sourcetype</fieldForValue> 
      <selectFirstChoice>true</selectFirstChoice>
    </input> 
    <input type="text" token="index" searchWhenChanged="true">
      <change>
        <unset token="form.dropdown"></unset>
      </change>
    </input> 
    <input type="time" token="field1" searchWhenChanged="true"> 
      <label></label> 
      <default> 
        <earliest>-15m</earliest> 
        <latest>now</latest> 
      </default> 
    </input> 
  </fieldset> 
  <row> 
    <panel> 
      <chart> 
        <search> 
          <query>index=_internal | timechart count</query> 
          <earliest>$field1.earliest$</earliest> 
          <latest>$field1.latest$</latest> 
        </search> 
        <option name="charting.chart">line</option> 
      </chart> 
    </panel> 
  </row> 
</form>

View solution in original post

Highlighted

Re: selectFirstChoice not working in dynamic dropdowns after update of generating search

Explorer

This worked for me although I was confused at first by the ordering but it's that the dropdown gets auto-reset and reselected each time index is changed.

0 Karma
Highlighted

Re: selectFirstChoice not working in dynamic dropdowns after update of generating search

Engager

This worked like a charm. Thanks!

0 Karma
Highlighted

Re: selectFirstChoice not working in dynamic dropdowns after update of generating search

Builder

Thank you, Kind Sir. This turned out to be trickier than I expected.

0 Karma
Highlighted

Re: selectFirstChoice not working in dynamic dropdowns after update of generating search

Splunk Employee
Splunk Employee

Works beautifully !! Is there any way that the dropdown value can be reset to its default value?

0 Karma