<?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: Using tokens in XLM dashboard table &amp;quot;fields&amp;quot; tag- fields won't update dynamically in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Using-tokens-in-XLM-dashboard-table-quot-fields-quot-tag-fields/m-p/490413#M136941</link>
    <description>&lt;P&gt;@niketnilay&lt;BR /&gt;
Well, that was easy. Thank you very much! Never occurred to me to rename with the underscore character.  I appreciate your time!&lt;/P&gt;</description>
    <pubDate>Wed, 11 Mar 2020 12:13:20 GMT</pubDate>
    <dc:creator>etoombs</dc:creator>
    <dc:date>2020-03-11T12:13:20Z</dc:date>
    <item>
      <title>Using tokens in XLM dashboard table "fields" tag- fields won't update dynamically</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-tokens-in-XLM-dashboard-table-quot-fields-quot-tag-fields/m-p/490411#M136939</link>
      <description>&lt;P&gt;I have an XML form that has a select box control that allows users to select the fields they want displayed in the output table.  The selected options are stored in a token called "$fields$".  The input is set to search on change.&lt;/P&gt;

&lt;P&gt;In the dashboard, if I use &lt;EM&gt;|table $fields$&lt;/EM&gt; at the end of my search, the results table is updated every time a field is checked or unchecked, which is the action I'm looking for.  However, the limitation of this is that I can't remove fields the users don't need to see if I want to keep them for drilldown.&lt;/P&gt;

&lt;P&gt;As an alternative, I tried adding the fields tag, with $fields$ for the list and removing the table command.  This effectively works at hiding the extra columns and keeping the data so that I can use it for drilldown, but it doesn't update dynamically as they are selecting/unselecting the field names. &lt;/P&gt;

&lt;P&gt;I want the best of both worlds - I want the fields to update dynamically as clicked and to be able to retain data in the row for drilldown features.  &lt;STRONG&gt;Is there a way to do this?&lt;/STRONG&gt;  It's multiple fields, but I'll always be able to control the field names. I'm open to using javascript on it if needed - I just haven't been able to figure out how.&lt;/P&gt;

&lt;P&gt;A limited version of my xml is below (with some choices removed, just for brevity)&lt;/P&gt;

&lt;P&gt;______________________&lt;STRONG&gt;&lt;EM&gt;The select box&lt;/EM&gt;&lt;/STRONG&gt;______________________&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;input type="checkbox" id="input_checkbox_horizontal1" searchWhenChanged="true" depends="$vsmacro$" token="fields"&amp;gt;
      &amp;lt;label&amp;gt;Select Fields to Display&amp;lt;/label&amp;gt;
      &amp;lt;choice value="&amp;amp;quot;VM Team Message&amp;amp;quot;"&amp;gt;VM Team Message&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="&amp;amp;quot;Last Observed&amp;amp;quot;"&amp;gt;Last Observed&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="&amp;amp;quot;Severity&amp;amp;quot;"&amp;gt;Severity&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="&amp;amp;quot;IP Address&amp;amp;quot;"&amp;gt;IP Address&amp;lt;/choice&amp;gt;
       &amp;lt;choice value="&amp;amp;quot;See Also&amp;amp;quot;"&amp;gt;See Also&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="&amp;amp;quot;CVSS Base Score&amp;amp;quot;"&amp;gt;CVSS Base Score&amp;lt;/choice&amp;gt;
    Notes&amp;amp;quot;,&amp;amp;quot;Note Expiration&amp;amp;quot;"&amp;gt;SLM Notes Information&amp;lt;/choice&amp;gt;
      &amp;lt;delimiter&amp;gt;,&amp;lt;/delimiter&amp;gt;
      &amp;lt;default&amp;gt;"""Last Observed""","""Severity""","""IP Address"""&amp;lt;/default&amp;gt;
      &amp;lt;initialValue&amp;gt;"Last Observed","Severity","IP Address",&amp;lt;/initialValue&amp;gt;
    &amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;_____________________&lt;STRONG&gt;&lt;EM&gt;the tables option&lt;/EM&gt;&lt;/STRONG&gt;________________&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   &amp;lt;query&amp;gt;[...a working search....] |table Directives $fields$   &amp;lt;/query&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will automatically update (I'd assume because of the searchWhenChanged control on the box.)&lt;/P&gt;

&lt;P&gt;_____________&lt;STRONG&gt;&lt;EM&gt;the fields option _&lt;/EM&gt;&lt;/STRONG&gt;_______________&lt;BR /&gt;
    &lt;TABLE id="DataTable"&gt;&lt;P&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        &amp;lt;search id="MySearch" base="BaseSearch"&amp;gt;

          &amp;lt;query&amp;gt;|[...a working search...]
           &amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;10&amp;lt;/option&amp;gt;
        [...removed a bunch of other "option" tags"...]
       &amp;lt;fields&amp;gt;$fields$&amp;lt;/fields&amp;gt;

        &amp;lt;drilldown&amp;gt;
         [...removed all the drilldown conditions...]
        &amp;lt;/drilldown&amp;gt;
      &amp;lt;/table&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any help you might be able to provide is appreciated!!!!&lt;/P&gt;&lt;/TABLE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 02:13:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-tokens-in-XLM-dashboard-table-quot-fields-quot-tag-fields/m-p/490411#M136939</guid>
      <dc:creator>etoombs</dc:creator>
      <dc:date>2020-03-11T02:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using tokens in XLM dashboard table "fields" tag- fields won't update dynamically</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-tokens-in-XLM-dashboard-table-quot-fields-quot-tag-fields/m-p/490412#M136940</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/115436"&gt;@etoombs&lt;/a&gt; you can use an independent search to process the check box selection and prepare a dummy SPL to rename each selected field name prefixed with underscore &lt;CODE&gt;_&lt;/CODE&gt;. This way fields prefixed with underscore will be hidden from Table fields however, at the same time they will be available for drill-down using &lt;CODE&gt;$row._yourHiddenFieldName$&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Please try out and confirm the following run anywhere example based on Splunk's _internal index, where default hidden fields are mongod, splunkd and splunkd_ui_access.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;Checkbox Based Table Field Filter with Drilldown&amp;lt;/label&amp;gt;
  &amp;lt;!-- Indepedent Search to process Check Box selection and create hidden table fields using underscore prefix fieldnames--&amp;gt;
  &amp;lt;!-- For Example: 
                    "mongod" selection in checkbox results in SPL "| rename mongod as _mongod"
                    "mongod splunkd" selection in checkbox results in "| rename mongod as _mongod, splunkd as _splunkd"
  PS: Splunk search result fields prefixed with underscore "_" are hidden from table. But can be used for drilldown using $row._fieldname$ for example $row._mongod$ or $row._splunkd$
  --&amp;gt;
  &amp;lt;search&amp;gt;
    &amp;lt;query&amp;gt;
| makeresults 
| fields - _time 
| eval originalSelection=split("$tokSourceTypes$"," ")
| mvexpand originalSelection 
| streamstats count as rowNum 
| eventstats max(rowNum) as maxRowNum 
| eval hiddenSelection=if(maxRowNum==rowNum," ".originalSelection." as _".originalSelection,
    " ".originalSelection." as _".originalSelection. ",") 
| stats list(hiddenSelection) as hiddenSelection 
| nomv hiddenSelection
| eval hiddenSelection="rename ".hiddenSelection
    &amp;lt;/query&amp;gt;
    &amp;lt;done&amp;gt;
      &amp;lt;set token="tokSelectedFields"&amp;gt;$result.hiddenSelection$&amp;lt;/set&amp;gt;
    &amp;lt;/done&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="checkbox" token="tokSourceTypes" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;Sourcetypes&amp;lt;/label&amp;gt;
      &amp;lt;fieldForLabel&amp;gt;sourcetype&amp;lt;/fieldForLabel&amp;gt;
      &amp;lt;fieldForValue&amp;gt;sourcetype&amp;lt;/fieldForValue&amp;gt;
      &amp;lt;search&amp;gt;
        &amp;lt;query&amp;gt;| tstats count where index=_internal by sourcetype
| fields sourcetype&amp;lt;/query&amp;gt;
        &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
      &amp;lt;/search&amp;gt;
      &amp;lt;default&amp;gt;mongod,splunkd,splunkd_ui_access&amp;lt;/default&amp;gt;
      &amp;lt;delimiter&amp;gt; &amp;lt;/delimiter&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| tstats count where index=_internal by sourcetype
| transpose 0 column_name="sourcetype" header_field="sourcetype"
| $tokSelectedFields$ &amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
        &amp;lt;drilldown&amp;gt;
          &amp;lt;set token="tokMongod"&amp;gt;$row._mongod$&amp;lt;/set&amp;gt;
          &amp;lt;set token="tokSplunkd"&amp;gt;$row._splunkd$&amp;lt;/set&amp;gt;
          &amp;lt;set token="tokSplunkdUIAccess"&amp;gt;$row._splunkd_ui_access$&amp;lt;/set&amp;gt;
        &amp;lt;/drilldown&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;div&amp;gt;
          &amp;lt;h2&amp;gt;Drilldown to see Hidden Column Values (default hidden fields are mongod, splunkd and splunkd_ui_access)&amp;lt;/h2&amp;gt;
          &amp;lt;div&amp;gt;mongod: $tokMongod$&amp;lt;/div&amp;gt;
          &amp;lt;div&amp;gt;splunkd: $tokSplunkd$&amp;lt;/div&amp;gt;
          &amp;lt;div&amp;gt;splunkd_ui_access: $tokSplunkdUIAccess$&amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:36:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-tokens-in-XLM-dashboard-table-quot-fields-quot-tag-fields/m-p/490412#M136940</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-30T04:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Using tokens in XLM dashboard table "fields" tag- fields won't update dynamically</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-tokens-in-XLM-dashboard-table-quot-fields-quot-tag-fields/m-p/490413#M136941</link>
      <description>&lt;P&gt;@niketnilay&lt;BR /&gt;
Well, that was easy. Thank you very much! Never occurred to me to rename with the underscore character.  I appreciate your time!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 12:13:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-tokens-in-XLM-dashboard-table-quot-fields-quot-tag-fields/m-p/490413#M136941</guid>
      <dc:creator>etoombs</dc:creator>
      <dc:date>2020-03-11T12:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using tokens in XLM dashboard table "fields" tag- fields won't update dynamically</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-tokens-in-XLM-dashboard-table-quot-fields-quot-tag-fields/m-p/490414#M136942</link>
      <description>&lt;P&gt;Anytime. Field names prefixed with underscore was a trick I learnt from @woodcock &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 13:22:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-tokens-in-XLM-dashboard-table-quot-fields-quot-tag-fields/m-p/490414#M136942</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-03-11T13:22:41Z</dc:date>
    </item>
  </channel>
</rss>

