Dashboards & Visualizations

How can I set a dynamic default value in a dropdown (Simple XML)

chris
Motivator

Is it possible to configure the dropdown input to take the first row returned by the populating Search as its default?
If I configure the dropdown as follows it just has an empty field as its default.

<input type="dropdown" token="source" searchWhenChanged="true">
  <label>Select a Sourcetype:</label>
  <populatingSearch fieldForValue="sourcetype" fieldForLabel="sourcetype" earliest="-24h" latest="now">
    <![CDATA[index=_internal | stats count by sourcetype]]>
  </populatingSearch>
</input>

Thanks,
Chris

1 Solution

nfilippi_splunk
Splunk Employee
Splunk Employee

As of Splunk 6.0.2, you can now use "selectFirstChoice" to populate the form input with the first returned value.

  <input type="dropdown" token="source" searchWhenChanged="true">
     <label>Select a Sourcetype:</label>
     <populatingSearch fieldForValue="sourcetype" fieldForLabel="sourcetype" earliest="-24h" latest="now">
        <![CDATA[index=_internal | stats count by sourcetype]]>
     </populatingSearch>
     <selectFirstChoice>true</selectFirstChoice>
  </input>

View solution in original post

nfilippi_splunk
Splunk Employee
Splunk Employee

As of Splunk 6.0.2, you can now use "selectFirstChoice" to populate the form input with the first returned value.

  <input type="dropdown" token="source" searchWhenChanged="true">
     <label>Select a Sourcetype:</label>
     <populatingSearch fieldForValue="sourcetype" fieldForLabel="sourcetype" earliest="-24h" latest="now">
        <![CDATA[index=_internal | stats count by sourcetype]]>
     </populatingSearch>
     <selectFirstChoice>true</selectFirstChoice>
  </input>

mclane1
Path Finder

Thank you very much for this tip.

It doesn't work for me on 8.2.0 in type="multiselect" 😭

 

0 Karma

grittonc
Contributor

Still working in v 7.0.8.

helge
Builder

It took me a while to figure out that this does not work for multiselect inputs. Why?

nishantmishra21
Engager

Any update how this has changed in version 6.5 ? I am getting 'not a valid' node as warning.

0 Karma

josefa
Path Finder

Also working in v6.2.3

 <input type="dropdown" token="field2" searchWhenChanged="true">
      <label>Web application</label>
      <search>
        <query>query</query>
        <earliest>$field1.earliest$</earliest>
          <latest>$field1.latest$</latest>
      </search>
      <fieldForLabel>WebApp</fieldForLabel>
      <fieldForValue>WebApp</fieldForValue>
      <selectFirstChoice>true</selectFirstChoice>
    </input>

Lazarix
Communicator

Try this on for size:

<param name="search">sourcetype=_internal earliest=-24h |fields host|dedup host
</param>
<param name="label">Select Name</param>
<param name="settingToCreate">host_setting</param>
<param name="searchFieldsToDisplay">
  <list>
    <param name="value">host</param>
    <param name="label">host</param>
  </list>
</param>

This should help you get what you want. You can get it to populate the dropdown based on "searchfieldsToDisplay"

0 Karma

nfilippi_splunk
Splunk Employee
Splunk Employee

This is advanced xml

0 Karma

somesoni2
Revered Legend
0 Karma

harshal_chakran
Builder

Hi Chris,
If you have got the solution can you please share it with me.Even I'm facing the same issue.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...