I have a dashboard with dynamically populated dropdown inputs. Selecting input A sets token_A that the input B relies on for its populating search. I used + to unset token_B when the selection in input A changes and this works just fine unless I reload the browser after I've made my selection; if I do this token_B resets but the first option is not selected.
Here is input A (A list of available Datamodels):
<input type="dropdown" token="data_model" searchWhenChanged="false">
<label>Data Model</label>
<search>
<query>| rest /services/datamodel/model | search eai:acl.app!=search | table displayName title eai:acl.app | sort displayName</query>
</search>
<fieldForLabel>displayName</fieldForLabel>
<fieldForValue>title</fieldForValue>
<change>
<unset token="form.root_object_name"></unset>
</change>
</input>
Here is input B (Datamodel Root Object Name):
<input type="dropdown" token="root_object_name" searchWhenChanged="true">
<label>Root Object Name</label>
<selectFirstChoice>true</selectFirstChoice>
<fieldForLabel>object_name</fieldForLabel>
<fieldForValue>object</fieldForValue>
<search>
<query>| datamodel $data_model$ | spath | rename "objects{}.displayName" as object_name "objects{}.objectName" as object | table object | mvexpand object | head 1</query>
<earliest>-24h@h</earliest>
<latest>now</latest>
</search>
I've read questions that lead me to a solution but it doesn't seem to work when I reload my dashboard. I'm using Splunk 6.5.2.
@dflodstorm... First of all sorry that I was too fixated on value for dropdown B being cleared on refresh and did not pay attention to selectFirstChoice working for the second time onward.
Since selectFirstChoice will not work after you refresh dashboard, and you are using second dropdown as a point to re-use a value rom your first search in your second search... I would suggest trying the following option instead.
This uses a search instead of second dropdown. The search preview event handler will allow you to access search result however only from the first row. This is a caveat of search preview event handler to return only the first row, which would work in your favor since you want only the first value selected by default.
<input type="dropdown" token="data_model" searchWhenChanged="true">
<label>Data Model</label>
<selectFirstChoice>true</selectFirstChoice>
<search>
<query>| rest /services/datamodel/model | table displayName title eai:acl.app | sort displayName | table displayName title </query>
</search>
<fieldForLabel>displayName</fieldForLabel>
<fieldForValue>title</fieldForValue>
<change>
<condition>
<set token="Title">$value$</set>
</condition>
</change>
</input>
</fieldset>
<search>
<query>| datamodel $Title$ | spath | rename "objects{}.displayName" as object_name "objects{}.objectName" as object | table object_name object | mvexpand object_name | mvexpand object | head 1</query>
<preview>
<condition>
<set token="Object">$result.object$</set>
</condition>
</preview>
</search>
PS: I have also turned on selectFirstChoice for the first time to provide your dashboard with a default value to start with. You can print tokens $Title$ and $Object$ in your dashboard to test behavior of both during refresh and clearing up of the URL querystring.