<?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 TimeRangeView properties in SearchBarView break common.js - Bug? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/TimeRangeView-properties-in-SearchBarView-break-common-js-Bug/m-p/529369#M9495</link>
    <description>&lt;P&gt;Hey guys,&lt;/P&gt;&lt;P&gt;according to the Splunk documentation for &lt;FONT face="arial,helvetica,sans-serif" color="#0000FF"&gt;compref_searchbar&lt;/FONT&gt;, the properties of the internal timerange created by the search bar are configurable via&amp;nbsp; &lt;FONT face="courier new,courier"&gt;timerange_*&lt;/FONT&gt;&amp;nbsp; (see URLs below) . However, when I try to set the dialogOptions property via&amp;nbsp; &lt;FONT face="courier new,courier"&gt;timerange_dialogOptions&lt;/FONT&gt;&amp;nbsp; (using the &lt;FONT face="courier new,courier"&gt;mypresetsettings&lt;/FONT&gt; example dictionary given in the&amp;nbsp;documentation for &lt;FONT face="arial,helvetica,sans-serif" color="#0000FF"&gt;compref_timerange&lt;/FONT&gt;), I get a JS exception within my SimpleXML dashboard:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;common.js:1114 Uncaught TypeError: str.replace is not a function
    at Object.replaceTokens (common.js:1114)
    at Object.computeValue (common.js:1114)
    at child._pullPropertyValue (common.js:1114)
    at child._setBinding (common.js:1114)
    at common.js:1114
    at Function._.each._.forEach (common.js:1114)
    at child._updateBindingsForProperties (common.js:1114)
    at child.&amp;lt;anonymous&amp;gt; (common.js:1114)
    at triggerEvents (common.js:725)
    at child.trigger (common.js:725)
    at configure (dashboard.js:1178)
    at initialize (dashboard.js:1178)
    at Backbone.View (dashboard.js:669)
    at constructor (dashboard.js:1178)
    at child (dashboard.js:669)
    at _createTimeRange (dashboard.js:1178)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The basic example given in the WebFramework documention works fine otherwise. But once I try to limit the time range picker, it fails. Can anybody tell my, what (or if) I'm doing wrong? I've been trying Splunk 8.0.5 and 8.1.0 in the last version of Google Chrome - same result. The script is 1:1 identical with the documentation, except the &lt;FONT face="courier new,courier"&gt;timerange_*&lt;/FONT&gt; properties set.&lt;/P&gt;&lt;P&gt;I also tried defining it via the options and settings before rendering the search bar, but no visible effect. Probably, because porperties like &lt;FONT face="courier new,courier"&gt;dialogOptions&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;presets&lt;/FONT&gt; are only evaluated during the initialization phase, making subsequent changes useless.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;EDIT from the 17-NOV-2020&lt;/STRONG&gt;: After further investigations, I believe this is a bug, eventually happening in method _updateBindingsForProperties(): For some reasons, Splunk wants to replace tokens in the TimeRangeView properties when created by the SearchBarView . But once the passed property is an object or array (e. g. try passing&amp;nbsp; &lt;FONT face="courier new,courier"&gt;timerange_foo: {}&lt;/FONT&gt;&amp;nbsp; or&amp;nbsp;&amp;nbsp; &lt;FONT face="courier new,courier"&gt;timerange_foo: [] &lt;/FONT&gt;), str.replace() will fail. Unfortunately, I may not file a bug report - would have to task a customer for this. But is any developer reading here to confirm my observation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="5"&gt;Dashboard: demo.xml&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;form script="demo.js"&amp;gt;
  &amp;lt;label&amp;gt;demo&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;div id="mysearchbarview"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;/html&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search base="example-search"&amp;gt;
          &amp;lt;query&amp;gt;| search *&amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="5"&gt;&lt;BR /&gt;Script: demo.js&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;require([
    "splunkjs/mvc/searchmanager",
    "splunkjs/mvc/searchbarview",
    "splunkjs/mvc/simplexml/ready!"
], function(SearchManager, SearchBarView) {

    // Create the search manager
    var mysearch = new SearchManager({
        id: "example-search",
        status_buckets: 300,
        required_field_list: "*",
        preview: true,
        cache: true,
        autostart: false, // Prevent the search from running automatically
        search: "index=_internal | head 500" 
    });

    // Create the searchbar
    var mysearchbar = new SearchBarView({
        id: "example-searchbar",
        managerid: "example-search",
        timerange_earliest_time: "-24h@h",
        timerange_latest_time: "now",
        timerange_dialogOptions: {
          showPresets: false,
          showCustomRealTime: false,
          showCustomAdvanced:false
        },
        el: $("#mysearchbarview")
    }).render();

    // Listen for changes to the search query portion of the searchbar
    mysearchbar.on("change", function() {
        // Reset the search query (allows the search to run again,
        // even when the query is unchanged)
        mysearch.settings.unset("search");

        // Update the search query
        mysearch.settings.set("search", mysearchbar.val());

        // Run the search (because autostart=false)
        mysearch.startSearch();
    });

    // Listen for changes to the built-in timerange portion of the searchbar
    mysearchbar.timerange.on("change", function() {
        // Update the time range of the search
        mysearch.settings.set(mysearchbar.timerange.val()); 

        // Run the search (because autostart=false)
        mysearch.startSearch();
    });
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/DocumentationStatic/WebFramework/1.5/compref_searchbar.html" target="_blank" rel="noopener"&gt;https://docs.splunk.com/DocumentationStatic/WebFramework/1.5/compref_searchbar.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://docs.splunk.com/DocumentationStatic/WebFramework/1.5/compref_timerange.html" target="_blank" rel="noopener"&gt;https://docs.splunk.com/DocumentationStatic/WebFramework/1.5/compref_timerange.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 18 Nov 2020 08:54:16 GMT</pubDate>
    <dc:creator>smichalski</dc:creator>
    <dc:date>2020-11-18T08:54:16Z</dc:date>
    <item>
      <title>TimeRangeView properties in SearchBarView break common.js - Bug?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/TimeRangeView-properties-in-SearchBarView-break-common-js-Bug/m-p/529369#M9495</link>
      <description>&lt;P&gt;Hey guys,&lt;/P&gt;&lt;P&gt;according to the Splunk documentation for &lt;FONT face="arial,helvetica,sans-serif" color="#0000FF"&gt;compref_searchbar&lt;/FONT&gt;, the properties of the internal timerange created by the search bar are configurable via&amp;nbsp; &lt;FONT face="courier new,courier"&gt;timerange_*&lt;/FONT&gt;&amp;nbsp; (see URLs below) . However, when I try to set the dialogOptions property via&amp;nbsp; &lt;FONT face="courier new,courier"&gt;timerange_dialogOptions&lt;/FONT&gt;&amp;nbsp; (using the &lt;FONT face="courier new,courier"&gt;mypresetsettings&lt;/FONT&gt; example dictionary given in the&amp;nbsp;documentation for &lt;FONT face="arial,helvetica,sans-serif" color="#0000FF"&gt;compref_timerange&lt;/FONT&gt;), I get a JS exception within my SimpleXML dashboard:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;common.js:1114 Uncaught TypeError: str.replace is not a function
    at Object.replaceTokens (common.js:1114)
    at Object.computeValue (common.js:1114)
    at child._pullPropertyValue (common.js:1114)
    at child._setBinding (common.js:1114)
    at common.js:1114
    at Function._.each._.forEach (common.js:1114)
    at child._updateBindingsForProperties (common.js:1114)
    at child.&amp;lt;anonymous&amp;gt; (common.js:1114)
    at triggerEvents (common.js:725)
    at child.trigger (common.js:725)
    at configure (dashboard.js:1178)
    at initialize (dashboard.js:1178)
    at Backbone.View (dashboard.js:669)
    at constructor (dashboard.js:1178)
    at child (dashboard.js:669)
    at _createTimeRange (dashboard.js:1178)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The basic example given in the WebFramework documention works fine otherwise. But once I try to limit the time range picker, it fails. Can anybody tell my, what (or if) I'm doing wrong? I've been trying Splunk 8.0.5 and 8.1.0 in the last version of Google Chrome - same result. The script is 1:1 identical with the documentation, except the &lt;FONT face="courier new,courier"&gt;timerange_*&lt;/FONT&gt; properties set.&lt;/P&gt;&lt;P&gt;I also tried defining it via the options and settings before rendering the search bar, but no visible effect. Probably, because porperties like &lt;FONT face="courier new,courier"&gt;dialogOptions&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;presets&lt;/FONT&gt; are only evaluated during the initialization phase, making subsequent changes useless.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;EDIT from the 17-NOV-2020&lt;/STRONG&gt;: After further investigations, I believe this is a bug, eventually happening in method _updateBindingsForProperties(): For some reasons, Splunk wants to replace tokens in the TimeRangeView properties when created by the SearchBarView . But once the passed property is an object or array (e. g. try passing&amp;nbsp; &lt;FONT face="courier new,courier"&gt;timerange_foo: {}&lt;/FONT&gt;&amp;nbsp; or&amp;nbsp;&amp;nbsp; &lt;FONT face="courier new,courier"&gt;timerange_foo: [] &lt;/FONT&gt;), str.replace() will fail. Unfortunately, I may not file a bug report - would have to task a customer for this. But is any developer reading here to confirm my observation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="5"&gt;Dashboard: demo.xml&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;form script="demo.js"&amp;gt;
  &amp;lt;label&amp;gt;demo&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;div id="mysearchbarview"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;/html&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search base="example-search"&amp;gt;
          &amp;lt;query&amp;gt;| search *&amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="5"&gt;&lt;BR /&gt;Script: demo.js&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;require([
    "splunkjs/mvc/searchmanager",
    "splunkjs/mvc/searchbarview",
    "splunkjs/mvc/simplexml/ready!"
], function(SearchManager, SearchBarView) {

    // Create the search manager
    var mysearch = new SearchManager({
        id: "example-search",
        status_buckets: 300,
        required_field_list: "*",
        preview: true,
        cache: true,
        autostart: false, // Prevent the search from running automatically
        search: "index=_internal | head 500" 
    });

    // Create the searchbar
    var mysearchbar = new SearchBarView({
        id: "example-searchbar",
        managerid: "example-search",
        timerange_earliest_time: "-24h@h",
        timerange_latest_time: "now",
        timerange_dialogOptions: {
          showPresets: false,
          showCustomRealTime: false,
          showCustomAdvanced:false
        },
        el: $("#mysearchbarview")
    }).render();

    // Listen for changes to the search query portion of the searchbar
    mysearchbar.on("change", function() {
        // Reset the search query (allows the search to run again,
        // even when the query is unchanged)
        mysearch.settings.unset("search");

        // Update the search query
        mysearch.settings.set("search", mysearchbar.val());

        // Run the search (because autostart=false)
        mysearch.startSearch();
    });

    // Listen for changes to the built-in timerange portion of the searchbar
    mysearchbar.timerange.on("change", function() {
        // Update the time range of the search
        mysearch.settings.set(mysearchbar.timerange.val()); 

        // Run the search (because autostart=false)
        mysearch.startSearch();
    });
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/DocumentationStatic/WebFramework/1.5/compref_searchbar.html" target="_blank" rel="noopener"&gt;https://docs.splunk.com/DocumentationStatic/WebFramework/1.5/compref_searchbar.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://docs.splunk.com/DocumentationStatic/WebFramework/1.5/compref_timerange.html" target="_blank" rel="noopener"&gt;https://docs.splunk.com/DocumentationStatic/WebFramework/1.5/compref_timerange.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 08:54:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/TimeRangeView-properties-in-SearchBarView-break-common-js-Bug/m-p/529369#M9495</guid>
      <dc:creator>smichalski</dc:creator>
      <dc:date>2020-11-18T08:54:16Z</dc:date>
    </item>
  </channel>
</rss>

