Dashboards & Visualizations

Set token based on hidden search and query result

juvenile
Loves-to-Learn

I have a hidden search. When I have a result I want to set the token based on that result, otherwise if I don't have any results I want to set the token to *. However, this does not work for me yet (the no results part with setting the token to all).

 

 

<search id="latest_product_id">
    <query>
        | mysearch
        | head 1 
        | fields product_id
    </query>
    <earliest>-24h@h</earliest>
    <latest>now</latest>
    <refresh>60</refresh>

    <depends>
        <condition token="some_token">*</condition>
    </depends>

    <done>
        <condition match="'job.resultCount'!= 0">
            <set token="latest_product_id">$result.product_id$</set>
        </condition>
        <condition match="'job.resultCount'== 0">
            <set token="latest_product_id">*</set>
        </condition>
    </done>
</search>

 

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Where is "all" coming from? It is not shown in your source listing. Also, the depends block you have shown is not part of valid SimpleXML. How are you using the latest_product_id token?

0 Karma

juvenile
Loves-to-Learn

I updated the search:

 

<search depends="some_other_token">
    <query>
        | mysearch id in $some_other_token$
        | head 1 
        | fields product_id
    </query>
    <earliest>-24h@h</earliest>
    <latest>now</latest>
    <refresh>60</refresh>

    <done>
        <condition match="'job.resultCount'!= 0">
            <set token="form.some_token">$result.product_id$</set>
        </condition>
        <condition match="'job.resultCount'== 0">
            <set token="form.some_token">*</set>
        </condition>
    </done>
</search>

 

The all is an option in the following multiselect

<input id="select_abc" type="multiselect" token="some_token" searchWhenChanged="true">
    <default>*</default>

    <prefix>(</prefix>
    <suffix>)</suffix>
    <valuePrefix>"</valuePrefix>
    <valueSuffix>"</valueSuffix>

    <choice value="*">All</choice>
    <search base="base_search">
        <query>
            | search to fill dropdown options
            | fields label, product_id
        </query>
    </search>
    <fieldForLabel>label</fieldForLabel>
    <fieldForValue>product_id</fieldForValue>

    <delimiter>,</delimiter>
</input>

So I want to set the value of the above multiselect (seom_token) on init and when another dropdown (some_other_token) changed. some_other_token is used in the search above.

0 Karma
Get Updates on the Splunk Community!

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...