<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Is there a way to create a token from search results in simple XML similar to $results[0].fieldname$ in advanced XML? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176535#M50716</link>
    <description>&lt;P&gt;Here's an easy way!!&lt;BR /&gt;
see for reference: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Viz/tokens#Search_event_elements_and_job_properties" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Viz/tokens#Search_event_elements_and_job_properties&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;You need to set the token in the  section and call the result there. Here's a sample:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Maximum API calls in one hour over last 7 days&amp;lt;/title&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;title&amp;gt;Max hits for api: $max_api$&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;...&amp;lt;/query&amp;gt;
          ...
          &amp;lt;done&amp;gt;
            &amp;lt;set token="max_api"&amp;gt;$result.api$&amp;lt;/set&amp;gt;
          &amp;lt;/done&amp;gt;
        &amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 29 Sep 2020 13:16:00 GMT</pubDate>
    <dc:creator>feickertmd</dc:creator>
    <dc:date>2020-09-29T13:16:00Z</dc:date>
    <item>
      <title>Is there a way to create a token from search results in simple XML similar to $results[0].fieldname$ in advanced XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176523#M50704</link>
      <description>&lt;P&gt;I want to be able to use my search for a few things, i.e. a table then further search or html display based on certain values in the first row of results.&lt;/P&gt;

&lt;P&gt;In advanced XML and Sideview I used to be able to get information from the first row of a search's results by using $results[0].fieldname$.&lt;/P&gt;

&lt;P&gt;Can I do something similar in simple xml?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 22:30:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176523#M50704</guid>
      <dc:creator>helenashton</dc:creator>
      <dc:date>2015-01-08T22:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to create a token from search results in simple XML similar to $results[0].fieldname$ in advanced XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176524#M50705</link>
      <description>&lt;P&gt;To my knowledge there aren't any tokens in Simple XML that are auto-populated by running searches.&lt;/P&gt;

&lt;P&gt;You could create a SearchManager in JS and grab the results from that directly.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 22:50:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176524#M50705</guid>
      <dc:creator>dfoster_splunk</dc:creator>
      <dc:date>2015-01-08T22:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to create a token from search results in simple XML similar to $results[0].fieldname$ in advanced XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176525#M50706</link>
      <description>&lt;P&gt;Can't do that unfortunately as I don't have permission to upload js files - if I could include js in the dashboard I'd be good... but I can't seem to.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 22:51:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176525#M50706</guid>
      <dc:creator>helenashton</dc:creator>
      <dc:date>2015-01-08T22:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to create a token from search results in simple XML similar to $results[0].fieldname$ in advanced XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176526#M50707</link>
      <description>&lt;P&gt;Yeah there's no way to inline JS in Simple XML. It has to be included via [form script="foo_in_appserver_static.js].&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:36:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176526#M50707</guid>
      <dc:creator>dfoster_splunk</dc:creator>
      <dc:date>2020-09-28T18:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to create a token from search results in simple XML similar to $results[0].fieldname$ in advanced XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176527#M50708</link>
      <description>&lt;P&gt;Technically you could include inline JS in HTML dashboards converted from SimpleXML. Good to start development, bad for maintenance and larger-scale deployment later.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 23:29:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176527#M50708</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-01-08T23:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to create a token from search results in simple XML similar to $results[0].fieldname$ in advanced XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176528#M50709</link>
      <description>&lt;P&gt;Yup, which is why I don't want to do it that way.&lt;BR /&gt;
It really would be helpful (for maintenance) to have inline JavaScript - anyone know if it's on the plan?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jan 2015 15:21:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176528#M50709</guid>
      <dc:creator>helenashton</dc:creator>
      <dc:date>2015-01-09T15:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to create a token from search results in simple XML similar to $results[0].fieldname$ in advanced XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176529#M50710</link>
      <description>&lt;P&gt;[script] tags are explicitly stripped out of [html] blocks in Simple XML, which leads me to believe that inline JS is explicitly not on the plan due to security issues. If a regular visitor could edit a dashboard and insert [script] tags in an [html] block, you could potentially have cookie-stealing code and other issues.&lt;/P&gt;

&lt;P&gt;Anyone on the Simple XML team with a more authoritative answer?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jan 2015 18:38:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176529#M50710</guid>
      <dc:creator>dfoster_splunk</dc:creator>
      <dc:date>2015-01-09T18:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to create a token from search results in simple XML similar to $results[0].fieldname$ in advanced XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176530#M50711</link>
      <description>&lt;P&gt;I think it should be our choice (as developers of a dashboard) if we are prepared to accept any risks. It opens up SO many options of things we can do to improve our dashboards. We have been doing this a lot in advanced XML, but if the trend is towards simple XML, then this feature is really important to allow us to make our dashboards usable and maintainable.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jan 2015 18:46:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176530#M50711</guid>
      <dc:creator>helenashton</dc:creator>
      <dc:date>2015-01-09T18:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to create a token from search results in simple XML similar to $results[0].fieldname$ in advanced XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176531#M50712</link>
      <description>&lt;P&gt;I have had the need to do this myself a few times, and I just figured it out.  What you want to do is create a token that you can reference in HTML.  To do this dynamically, we can use a form input.  The important parts here are:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Use a dropdown input.&lt;/LI&gt;
&lt;LI&gt;Create a search that gives you the result that you want to tokenize.&lt;/LI&gt;
&lt;LI&gt;Hide the input by assigning a dummy &lt;EM&gt;depends&lt;/EM&gt; token in the input type.&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;Set the * selectFirstChoice* parameter to true.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;input type="dropdown" token="last_update" searchWhenChanged="true" depends="$justHideMe$"&amp;gt;
    &amp;lt;label&amp;gt;last_update&amp;lt;/label&amp;gt;
    &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;index=my_data_updates | head 1 | convert timeformat="%H:%M:%S on %m/%d/%Y" ctime(_time) AS last_update | table last_update&amp;lt;/query&amp;gt;
    &amp;lt;/search&amp;gt;
    &amp;lt;fieldForLabel&amp;gt;last_update&amp;lt;/fieldForLabel&amp;gt;
    &amp;lt;fieldForValue&amp;gt;last_update&amp;lt;/fieldForValue&amp;gt;
    &amp;lt;selectFirstChoice&amp;gt;true&amp;lt;/selectFirstChoice&amp;gt;
  &amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;You can now reference $last_update$ in your HTML panels.&lt;/P&gt;

&lt;P&gt;Check out my example "last updated" dashboard at the bottom of this App:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://splunkbase.splunk.com/app/2919/"&gt;https://splunkbase.splunk.com/app/2919/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2016 17:32:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176531#M50712</guid>
      <dc:creator>jdonn_splunk</dc:creator>
      <dc:date>2016-03-11T17:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to create a token from search results in simple XML similar to $results[0].fieldname$ in advanced XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176532#M50713</link>
      <description>&lt;P&gt;To @jdonn's point, this functionality is now available in the newer versions of Splunk.&lt;/P&gt;

&lt;P&gt;Here's some docs to elaborate:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;New tokens for search job related status: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.3/Viz/tokens#Define_search_tokens"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.3/Viz/tokens#Define_search_tokens&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Get specific values from specific items in the result set: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.3/Viz/tokens#Define_tokens_for_dynamic_drilldown"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.3/Viz/tokens#Define_tokens_for_dynamic_drilldown&lt;/A&gt; and &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.3/Viz/Understandbasictableandchartdrilldownactions#Drilldown_event_tokens"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.3/Viz/Understandbasictableandchartdrilldownactions#Drilldown_event_tokens&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Set and unset variables from search results: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.3/Viz/Understandbasictableandchartdrilldownactions#Dynamic_drilldown_elements"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.3/Viz/Understandbasictableandchartdrilldownactions#Dynamic_drilldown_elements&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Fri, 11 Mar 2016 19:20:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176532#M50713</guid>
      <dc:creator>sloshburch</dc:creator>
      <dc:date>2016-03-11T19:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to create a token from search results in simple XML similar to $results[0].fieldname$ in advanced XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176533#M50714</link>
      <description>&lt;P&gt;In case anyone wants an example, here is one that I just did:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;search id="minVal"&amp;gt;
           &amp;lt;query&amp;gt;| makeresults | eval minute_val=`cts_sm_minute_builder`&amp;lt;/query&amp;gt;
           &amp;lt;earliest&amp;gt;$t_picker.earliest$&amp;lt;/earliest&amp;gt;
    &amp;lt;latest&amp;gt;$t_picker.latest$&amp;lt;/latest&amp;gt;
           &amp;lt;finalized&amp;gt;
            &amp;lt;set token="minute_val"&amp;gt;$result.minute_val$&amp;lt;/set&amp;gt;&amp;gt;
           &amp;lt;/finalized&amp;gt;
         &amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where that macro is basically giving me back some calculated values based on the time picker entries&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2016 00:06:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176533#M50714</guid>
      <dc:creator>bcronrath</dc:creator>
      <dc:date>2016-11-15T00:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to create a token from search results in simple XML similar to $results[0].fieldname$ in advanced XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176534#M50715</link>
      <description>&lt;P&gt;Even in Splunk Simple XML &lt;STRONG&gt;$result.[fieldname]$&lt;/STRONG&gt; is available provided applicable &lt;STRONG&gt;only for the first row&lt;/STRONG&gt;. Please check the Search Event Handlers: &lt;BR /&gt;
1) &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.1/Viz/EventHandlerReference"&gt;http://docs.splunk.com/Documentation/Splunk/6.5.1/Viz/EventHandlerReference&lt;/A&gt;&lt;BR /&gt;
2) &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.1/Viz/tokens"&gt;http://docs.splunk.com/Documentation/Splunk/6.5.1/Viz/tokens&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;You can also check out the &lt;STRONG&gt;Splunk 6.x Dashboard Examples&lt;/STRONG&gt; App for &lt;STRONG&gt;Search Result Setter&lt;/STRONG&gt; example which calls out various search tokens. &lt;/P&gt;

&lt;P&gt;Please let me know if you need example for $result.[fieldname]$ token.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2016 06:01:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176534#M50715</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2016-11-15T06:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to create a token from search results in simple XML similar to $results[0].fieldname$ in advanced XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176535#M50716</link>
      <description>&lt;P&gt;Here's an easy way!!&lt;BR /&gt;
see for reference: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Viz/tokens#Search_event_elements_and_job_properties" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Viz/tokens#Search_event_elements_and_job_properties&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;You need to set the token in the  section and call the result there. Here's a sample:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Maximum API calls in one hour over last 7 days&amp;lt;/title&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;title&amp;gt;Max hits for api: $max_api$&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;...&amp;lt;/query&amp;gt;
          ...
          &amp;lt;done&amp;gt;
            &amp;lt;set token="max_api"&amp;gt;$result.api$&amp;lt;/set&amp;gt;
          &amp;lt;/done&amp;gt;
        &amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:16:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176535#M50716</guid>
      <dc:creator>feickertmd</dc:creator>
      <dc:date>2020-09-29T13:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to create a token from search results in simple XML similar to $results[0].fieldname$ in advanced XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176536#M50717</link>
      <description>&lt;P&gt;see my answer below&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 18:03:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-create-a-token-from-search-results-in-simple/m-p/176536#M50717</guid>
      <dc:creator>feickertmd</dc:creator>
      <dc:date>2017-03-17T18:03:35Z</dc:date>
    </item>
  </channel>
</rss>

