<?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 How to add dynamic value as default value in check box ? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-add-dynamic-value-as-default-value-in-check-box/m-p/304831#M57465</link>
    <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;

&lt;P&gt;Can we use dynamic value as default value for check box? currently am trying below code, but unfortunately don't know how to add my dynamic value &lt;CODE&gt;current_month_year&lt;/CODE&gt; as checked in my form&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="checkbox" token="currentdate"&amp;gt;
      &amp;lt;label&amp;gt;date&amp;lt;/label&amp;gt;
        &amp;lt;choice value="*"&amp;gt;ALL&amp;lt;/choice&amp;gt;
        &amp;lt;default&amp;gt;current_month_year&amp;lt;/default&amp;gt;

     &amp;lt;fieldForLabel&amp;gt;currentdate&amp;lt;/fieldForLabel&amp;gt;
      &amp;lt;fieldForValue&amp;gt;current_month_year&amp;lt;/fieldForValue&amp;gt;
      &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;| makeresults | eval current_month_year=strftime(now(),"%Y-%m") 
| table current_month_year&amp;lt;/query&amp;gt;
&amp;lt;/search&amp;gt;

      &amp;lt;valuePrefix&amp;gt;"&amp;lt;/valuePrefix&amp;gt;
      &amp;lt;valueSuffix&amp;gt;"&amp;lt;/valueSuffix&amp;gt;

      &amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can any one help me here &lt;/P&gt;</description>
    <pubDate>Wed, 12 Jul 2017 10:38:14 GMT</pubDate>
    <dc:creator>snehalk</dc:creator>
    <dc:date>2017-07-12T10:38:14Z</dc:date>
    <item>
      <title>How to add dynamic value as default value in check box ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-add-dynamic-value-as-default-value-in-check-box/m-p/304831#M57465</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;

&lt;P&gt;Can we use dynamic value as default value for check box? currently am trying below code, but unfortunately don't know how to add my dynamic value &lt;CODE&gt;current_month_year&lt;/CODE&gt; as checked in my form&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="checkbox" token="currentdate"&amp;gt;
      &amp;lt;label&amp;gt;date&amp;lt;/label&amp;gt;
        &amp;lt;choice value="*"&amp;gt;ALL&amp;lt;/choice&amp;gt;
        &amp;lt;default&amp;gt;current_month_year&amp;lt;/default&amp;gt;

     &amp;lt;fieldForLabel&amp;gt;currentdate&amp;lt;/fieldForLabel&amp;gt;
      &amp;lt;fieldForValue&amp;gt;current_month_year&amp;lt;/fieldForValue&amp;gt;
      &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;| makeresults | eval current_month_year=strftime(now(),"%Y-%m") 
| table current_month_year&amp;lt;/query&amp;gt;
&amp;lt;/search&amp;gt;

      &amp;lt;valuePrefix&amp;gt;"&amp;lt;/valuePrefix&amp;gt;
      &amp;lt;valueSuffix&amp;gt;"&amp;lt;/valueSuffix&amp;gt;

      &amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can any one help me here &lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 10:38:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-add-dynamic-value-as-default-value-in-check-box/m-p/304831#M57465</guid>
      <dc:creator>snehalk</dc:creator>
      <dc:date>2017-07-12T10:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to add dynamic value as default value in check box ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-add-dynamic-value-as-default-value-in-check-box/m-p/304832#M57466</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;This should do it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;default&amp;gt;$current_month_year$&amp;lt;/default&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jul 2017 11:08:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-add-dynamic-value-as-default-value-in-check-box/m-p/304832#M57466</guid>
      <dc:creator>knielsen</dc:creator>
      <dc:date>2017-07-12T11:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to add dynamic value as default value in check box ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-add-dynamic-value-as-default-value-in-check-box/m-p/304833#M57467</link>
      <description>&lt;P&gt;Hello Knielsen,&lt;/P&gt;

&lt;P&gt;its taking as string "$current_month_year$" its not taking value &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:50:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-add-dynamic-value-as-default-value-in-check-box/m-p/304833#M57467</guid>
      <dc:creator>snehalk</dc:creator>
      <dc:date>2020-09-29T14:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to add dynamic value as default value in check box ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-add-dynamic-value-as-default-value-in-check-box/m-p/304834#M57468</link>
      <description>&lt;P&gt;@snehalk, Checkbox input does not seem to &lt;STRONG&gt;accept token as default field&lt;/STRONG&gt;.&lt;BR /&gt;
Based on the example, seems like you want to use checkbox as toggle between All and Current Month. Instead of checkbox can you use radio input?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;input type="radio" token="currentdate"&amp;gt;
       &amp;lt;label&amp;gt;date&amp;lt;/label&amp;gt;
       &amp;lt;choice value="*"&amp;gt;ALL&amp;lt;/choice&amp;gt;
       &amp;lt;default&amp;gt;$tokCurrentMonthYear$&amp;lt;/default&amp;gt;
       &amp;lt;fieldForLabel&amp;gt;current_month_year&amp;lt;/fieldForLabel&amp;gt;
       &amp;lt;fieldForValue&amp;gt;current_month_year&amp;lt;/fieldForValue&amp;gt;
       &amp;lt;search&amp;gt;
           &amp;lt;query&amp;gt;| makeresults 
             | eval current_month_year=strftime(now(),"%Y-%m") 
             | table current_month_year&amp;lt;/query&amp;gt;
           &amp;lt;progress&amp;gt;
                   &amp;lt;set token="tokCurrentMonthYear"&amp;gt;$result.current_month_year$&amp;lt;/set&amp;gt;
           &amp;lt;/progress&amp;gt; 
       &amp;lt;/search&amp;gt;
       &amp;lt;valuePrefix&amp;gt;"&amp;lt;/valuePrefix&amp;gt;
       &amp;lt;valueSuffix&amp;gt;"&amp;lt;/valueSuffix&amp;gt;
 &amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Radio input allows passing default value as token: &lt;CODE&gt;&amp;lt;default&amp;gt;$tokCurrentMonthYear$&amp;lt;/default&amp;gt;&lt;/CODE&gt;. The same does not work with checkbox which treats it as string. &lt;STRONG&gt;This seems to be bug with Checkbox&lt;/STRONG&gt; which handles multiple value. So your task would be achievable only through custom JavaScript if you have a constraint to use checkbox.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 11:50:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-add-dynamic-value-as-default-value-in-check-box/m-p/304834#M57468</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-07-12T11:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to add dynamic value as default value in check box ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-add-dynamic-value-as-default-value-in-check-box/m-p/304835#M57469</link>
      <description>&lt;P&gt;Awesome!! Thank you so much!!  @niketnilay, its working as expected! now i can go with radio input, instated of checkbox for now.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 12:19:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-add-dynamic-value-as-default-value-in-check-box/m-p/304835#M57469</guid>
      <dc:creator>snehalk</dc:creator>
      <dc:date>2017-07-12T12:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to add dynamic value as default value in check box ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-add-dynamic-value-as-default-value-in-check-box/m-p/304836#M57470</link>
      <description>&lt;P&gt;@niketnilay, can we do the change in the order and label for radio? that is right now we are getting option like &lt;BR /&gt;
1. All &lt;BR /&gt;
2. 2017-07&lt;/P&gt;

&lt;P&gt;Can we get like &lt;BR /&gt;
1. Current Month&lt;BR /&gt;&lt;BR /&gt;
2. All&lt;/P&gt;

&lt;P&gt;Here "Current Month" contain value "2017-07"?&lt;/P&gt;

&lt;P&gt;Can you please help me here?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 14:51:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-add-dynamic-value-as-default-value-in-check-box/m-p/304836#M57470</guid>
      <dc:creator>snehalk</dc:creator>
      <dc:date>2017-07-13T14:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to add dynamic value as default value in check box ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-add-dynamic-value-as-default-value-in-check-box/m-p/304837#M57471</link>
      <description>&lt;P&gt;HI snehalk, Static options are displayed first followed by the results from the Dynamic Query. You can remove the static &lt;CODE&gt;&amp;lt;choice&amp;gt;&lt;/CODE&gt; All and move the same to Dynamic option using the following query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval current_month_year=strftime(now(),"%Y-%m") 
| append [
           | makeresults 
           | eval current_month_year="*" ]
| table current_month_year
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Another way to use query would be to use the following query,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval current_month_year=strftime(now(),"%Y-%m") 
| appendcols [
           | makeresults 
           | eval All="*" ]
| fields - _time
| transpose column_name="label"
| reverse
| rename "row 1" as value
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 15 Jul 2017 12:37:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-add-dynamic-value-as-default-value-in-check-box/m-p/304837#M57471</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-07-15T12:37:29Z</dc:date>
    </item>
  </channel>
</rss>

