I am having few dashboards, and I want to select one at a time from the dropdown list like when I select A the dashboard having the name as A will appear. Hope I'm questioning in the correct way.
@ajain0726 easy answer is as per what @Sukisen1981 mentioned refer to /data/ui/view Splunk REST API call, which will give you all view names. However, you would need to filter results on a lot of criteria like based on logged in user role only specific Dashboards should be visible. If you want only the Dashboards from current app/current user role you should mention the same in the rest call itself. For example:
| rest /serviceNS/admin/search/data/ui/views
Or, the following in Dashboard which pulls Current App Name (PS: Current User can be access by $env:user$ however, there can be multiple roles assigned to same user which can be accessed by another REST call i.e. /service/authentication/current-context
| rest /serviceNS/admin/$env:app$/data/ui/views
Further there can be permission specific to Apps/Dashboards which may show/hide the dashboard for logged in user. So it might not be completely straightforward to pull all dashboards in Dropdown, and you may need to perform testing and either correct permissions in Apps/Dashboards or filter results from Dropdown by applying filters to the REST API call to fetch dashboard names.
Following is a run anywhere Dashboard Example based on above approach which Populates Current User Roles and Apps that Current User has access to view some or the other dashboard. On selection on a Dashboard the same opens in a new window.
By default All roles are selected and the App is Current App.
Following is the Simple XML for mock screenshot provided above.
<form>
<label>Populate Dashboard in Dropdown</label>
<fieldset submitButton="false">
<input type="dropdown" token="tokRoles">
<label>User Roles</label>
<choice value="*">All</choice>
<default>*</default>
<fieldForLabel>roles</fieldForLabel>
<fieldForValue>roles</fieldForValue>
<search>
<query>| rest splunk_server=local /services/authentication/current-context
| table roles</query>
<earliest>-24h@h</earliest>
<latest>now</latest>
</search>
<change>
<condition value="*">
<set token="tokRole">-</set>
</condition>
<condition>
<set token="tokRole">$value$</set>
</condition>
</change>
</input>
<input type="dropdown" token="tokApps">
<label>Apps</label>
<choice value="*">All</choice>
<default>$env:app$</default>
<fieldForLabel>eai:appName</fieldForLabel>
<fieldForValue>eai:appName</fieldForValue>
<search>
<query>| rest splunk_server=local /servicesNS/$tokRole$/-/data/ui/views
| search (isVisible=1 isDashboard=1 "eai:type"="html" OR "eai:type"="views" ) ("eai:acl.perms.read"="*" OR "eai:acl.perms.read"="$tokRoles$") ("eai:appName"="*" OR "eai:appName"="$env:app$")
| eval label= label." (".'eai:appName'.")"
| dedup "eai:appName"
| table "eai:appName"</query>
<earliest>-24h@h</earliest>
<latest>now</latest>
</search>
<change>
<condition value="*">
<set token="tokApp">-</set>
</condition>
<condition>
<set token="tokApp">$value$</set>
</condition>
</change>
</input>
<input type="dropdown" token="tokDashboard">
<label>Dashboards</label>
<fieldForLabel>label</fieldForLabel>
<fieldForValue>title</fieldForValue>
<search>
<query>| rest splunk_server=local /servicesNS/$tokRole$/$tokApp$/data/ui/views
| search ( isDashboard=1 "eai:type"="html" OR "eai:type"="views" ) ("eai:acl.perms.read"="*" OR "eai:acl.perms.read"="$tokRole$") ("eai:appName"="$tokApps$")
| eval label= label." (".'eai:appName'.")"
| table label title
| dedup title</query>
<earliest>-24h@h</earliest>
<latest>now</latest>
</search>
<change>
<condition match="(isnotnull($value$))">
<link target="_blank">
/app/$tokApps$/$value$
</link>
</condition>
</change>
</input>
</fieldset>
<row>
<panel>
<single>
<title>Current App - $env:app$</title>
<search id="baseUserRolesRESTSearch">
<query>| rest splunk_server=local /services/authentication/current-context
| table roles</query>
<earliest>$earliest$</earliest>
<latest>$latest$</latest>
</search>
<option name="refresh.display">progressbar</option>
<option name="underLabel">Logged in user ( $env:user$ ) roles</option>
</single>
</panel>
</row>
</form>
If you try this as your search query are you able to receive all the dashboards returned as search results?
| rest /servicesNS/-/-/data/ui/views