<?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 Conditional Switcher always picks first tree in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Conditional-Switcher-always-picks-first-tree/m-p/118404#M44359</link>
    <description>&lt;P&gt;I've been dabbling with ConditionalSwitcher, but no matter what I use as the condition it always picks the first tree. &lt;/P&gt;

&lt;P&gt;It got to the point where I stripped out all the rest of my searches and advanced xml and just tried a ConditionalSwitcher on it's own.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;view onunloadCancelJobs="true" template="dashboard.html"&amp;gt;
&amp;lt;label&amp;gt;ConditionalSwitcher Test&amp;lt;/label&amp;gt;
&amp;lt;module name="AccountBar" layoutPanel="appHeader" /&amp;gt;
&amp;lt;module name="SideviewUtils" layoutPanel="appHeader" /&amp;gt;
&amp;lt;module name="AppBar" layoutPanel="appHeader" /&amp;gt;

&amp;lt;module name="Message" layoutPanel="messaging"&amp;gt;
    &amp;lt;param name="filter"&amp;gt;*&amp;lt;/param&amp;gt;
    &amp;lt;param name="maxSize"&amp;gt;2&amp;lt;/param&amp;gt;
    &amp;lt;param name="clearOnJobDispatch"&amp;gt;False&amp;lt;/param&amp;gt;
&amp;lt;/module&amp;gt;

&amp;lt;!-- if 1 = 0  --&amp;gt;
&amp;lt;module name="ConditionalSwitcher" layoutPanel="panel_row1_col1"&amp;gt;
    &amp;lt;param name="mode"&amp;gt;independent&amp;lt;/param&amp;gt;
    &amp;lt;param name="condition"&amp;gt;'("1"=="0")'&amp;lt;/param&amp;gt;
    &amp;lt;!-- then  true --&amp;gt;
    &amp;lt;module name="HTML" layoutPanel="panel_row1_col1"&amp;gt;
        &amp;lt;param name="html"&amp;gt;
            First
        &amp;lt;/param&amp;gt;
    &amp;lt;/module&amp;gt;
    &amp;lt;!-- else false --&amp;gt;
    &amp;lt;module name="HTML" layoutPanel="panel_row1_col1"&amp;gt;
        &amp;lt;param name="html"&amp;gt;
            Second                                              
      &amp;lt;/param&amp;gt;
    &amp;lt;/module&amp;gt;
&amp;lt;/module&amp;gt;
&amp;lt;!-- end ifs --&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;/P&gt;

&lt;P&gt;As you can hopefully tell, the condition for switching is 1=0, if true it prints First, if false it prints Second.&lt;/P&gt;

&lt;P&gt;It always prints First - no matter what.&lt;/P&gt;

&lt;P&gt;HELP!&lt;/P&gt;

&lt;P&gt;What am I doing wrong?&lt;/P&gt;

&lt;P&gt;Cheers, Keith&lt;/P&gt;</description>
    <pubDate>Thu, 03 Apr 2014 05:05:21 GMT</pubDate>
    <dc:creator>kmugglet</dc:creator>
    <dc:date>2014-04-03T05:05:21Z</dc:date>
    <item>
      <title>Conditional Switcher always picks first tree</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Conditional-Switcher-always-picks-first-tree/m-p/118404#M44359</link>
      <description>&lt;P&gt;I've been dabbling with ConditionalSwitcher, but no matter what I use as the condition it always picks the first tree. &lt;/P&gt;

&lt;P&gt;It got to the point where I stripped out all the rest of my searches and advanced xml and just tried a ConditionalSwitcher on it's own.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;view onunloadCancelJobs="true" template="dashboard.html"&amp;gt;
&amp;lt;label&amp;gt;ConditionalSwitcher Test&amp;lt;/label&amp;gt;
&amp;lt;module name="AccountBar" layoutPanel="appHeader" /&amp;gt;
&amp;lt;module name="SideviewUtils" layoutPanel="appHeader" /&amp;gt;
&amp;lt;module name="AppBar" layoutPanel="appHeader" /&amp;gt;

&amp;lt;module name="Message" layoutPanel="messaging"&amp;gt;
    &amp;lt;param name="filter"&amp;gt;*&amp;lt;/param&amp;gt;
    &amp;lt;param name="maxSize"&amp;gt;2&amp;lt;/param&amp;gt;
    &amp;lt;param name="clearOnJobDispatch"&amp;gt;False&amp;lt;/param&amp;gt;
&amp;lt;/module&amp;gt;

&amp;lt;!-- if 1 = 0  --&amp;gt;
&amp;lt;module name="ConditionalSwitcher" layoutPanel="panel_row1_col1"&amp;gt;
    &amp;lt;param name="mode"&amp;gt;independent&amp;lt;/param&amp;gt;
    &amp;lt;param name="condition"&amp;gt;'("1"=="0")'&amp;lt;/param&amp;gt;
    &amp;lt;!-- then  true --&amp;gt;
    &amp;lt;module name="HTML" layoutPanel="panel_row1_col1"&amp;gt;
        &amp;lt;param name="html"&amp;gt;
            First
        &amp;lt;/param&amp;gt;
    &amp;lt;/module&amp;gt;
    &amp;lt;!-- else false --&amp;gt;
    &amp;lt;module name="HTML" layoutPanel="panel_row1_col1"&amp;gt;
        &amp;lt;param name="html"&amp;gt;
            Second                                              
      &amp;lt;/param&amp;gt;
    &amp;lt;/module&amp;gt;
&amp;lt;/module&amp;gt;
&amp;lt;!-- end ifs --&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;/P&gt;

&lt;P&gt;As you can hopefully tell, the condition for switching is 1=0, if true it prints First, if false it prints Second.&lt;/P&gt;

&lt;P&gt;It always prints First - no matter what.&lt;/P&gt;

&lt;P&gt;HELP!&lt;/P&gt;

&lt;P&gt;What am I doing wrong?&lt;/P&gt;

&lt;P&gt;Cheers, Keith&lt;/P&gt;</description>
      <pubDate>Thu, 03 Apr 2014 05:05:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Conditional-Switcher-always-picks-first-tree/m-p/118404#M44359</guid>
      <dc:creator>kmugglet</dc:creator>
      <dc:date>2014-04-03T05:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Switcher always picks first tree</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Conditional-Switcher-always-picks-first-tree/m-p/118405#M44360</link>
      <description>&lt;P&gt;I think it's just because you're wrapping the condition in single quotes?  So the "condition" you're asking it to evaluate is just a big string.   Strings evaluate to true in a boolean context in JS, so it's doing so here and thus always picking the first child.   Remove the single quotes and it should be fine. &lt;/P&gt;

&lt;P&gt;Since you're using Sideview Utils in this view, you may want to look into replacing Splunk's ConditionalSwitcher module with the simple conditional abilities of the Sideview ValueSetter module in combination with the Sideview Switcher module. This can give you more flexibility than the old ConditionalSwitcher, which could only switch between one or two branches.    &lt;A href="http://sideviewapps.com/apps/sideview-utils"&gt;http://sideviewapps.com/apps/sideview-utils&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;UPDATE:   Aha!.  The other problem is that the way ConditionalSwitcher is implemented, it will only ever check the condition in two cases   1) When the module receives a push from upstream,   and 2) when the currently running job it has access to has made some progress towards completion - (in this case it will only check if the condition param has "job" anywhere in it)&lt;/P&gt;

&lt;P&gt;In your example there is no push from above (eg via an autoRun="True" attribute upstream), and so the ConditionalSwitcher actually never checks it's condition so the first child remains selected simply because it's selected by default.&lt;/P&gt;

&lt;P&gt;You can rework the example a bit to have an autoRun="True" on a module upstream somewhere and it will start working.    Here is a modified view. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;view onunloadCancelJobs="true" template="dashboard.html"&amp;gt;
&amp;lt;label&amp;gt;ConditionalSwitcher Test&amp;lt;/label&amp;gt;
&amp;lt;module name="AccountBar" layoutPanel="appHeader" /&amp;gt;
&amp;lt;module name="SideviewUtils" layoutPanel="appHeader" /&amp;gt;
&amp;lt;module name="AppBar" layoutPanel="appHeader" /&amp;gt;

&amp;lt;module name="Message" layoutPanel="messaging"&amp;gt;
    &amp;lt;param name="filter"&amp;gt;*&amp;lt;/param&amp;gt;
    &amp;lt;param name="maxSize"&amp;gt;2&amp;lt;/param&amp;gt;
    &amp;lt;param name="clearOnJobDispatch"&amp;gt;False&amp;lt;/param&amp;gt;
&amp;lt;/module&amp;gt;

&amp;lt;!-- if 1 = 0  --&amp;gt;
&amp;lt;module name="URLLoader" layoutPanel="panel_row1_col1" autoRun="True"&amp;gt;
  &amp;lt;module name="ConditionalSwitcher"&amp;gt;
    &amp;lt;param name="mode"&amp;gt;independent&amp;lt;/param&amp;gt;
    &amp;lt;param name="condition"&amp;gt;"1"=="0"&amp;lt;/param&amp;gt;
    &amp;lt;!-- then  true --&amp;gt;
    &amp;lt;module name="HTML"&amp;gt;
      &amp;lt;param name="html"&amp;gt;
        First
      &amp;lt;/param&amp;gt;
    &amp;lt;/module&amp;gt;
    &amp;lt;!-- else false --&amp;gt;
    &amp;lt;module name="HTML"&amp;gt;
      &amp;lt;param name="html"&amp;gt;
        Second
      &amp;lt;/param&amp;gt;
    &amp;lt;/module&amp;gt;
  &amp;lt;/module&amp;gt;
&amp;lt;/module&amp;gt;
&amp;lt;!-- end ifs --&amp;gt;
&amp;lt;/view&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Apr 2014 06:43:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Conditional-Switcher-always-picks-first-tree/m-p/118405#M44360</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2014-04-03T06:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Switcher always picks first tree</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Conditional-Switcher-always-picks-first-tree/m-p/118406#M44361</link>
      <description>&lt;P&gt;Thanks for the pointer on the single quotes, however this still doesn't work.&lt;BR /&gt;
I've gone as far as putting 0, false , and "Not flipping true" in the condition param, all to no avail.&lt;BR /&gt;
It always comes up true and picks the first tree.&lt;BR /&gt;
Can someone post a simple example where it definitely picks the second tree.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Apr 2014 20:20:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Conditional-Switcher-always-picks-first-tree/m-p/118406#M44361</guid>
      <dc:creator>kmugglet</dc:creator>
      <dc:date>2014-04-03T20:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Switcher always picks first tree</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Conditional-Switcher-always-picks-first-tree/m-p/118407#M44362</link>
      <description>&lt;P&gt;I see. The ConditionalSwitcher has a bug in it where if it never receives a push from upstream, it will never check your condition.  I updated my answer above.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Apr 2014 23:09:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Conditional-Switcher-always-picks-first-tree/m-p/118407#M44362</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2014-04-03T23:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Switcher always picks first tree</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Conditional-Switcher-always-picks-first-tree/m-p/118408#M44363</link>
      <description>&lt;P&gt;Thanks for that, I've got it past the true/false bit now...&lt;BR /&gt;
All I have to do now is get it to recognise my token&lt;BR /&gt;
that I set upstream. &lt;BR /&gt;
In my "real" XML with a token of $rowTitle$&lt;BR /&gt;
&lt;PRE&gt;&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;&lt;MODULE name="ConditionalSwitcher"&gt;&lt;BR /&gt;
&lt;OBJECT&gt;&lt;PARAM name="mode" /&gt;independent&lt;BR /&gt;
&lt;PARAM name="condition" /&gt;(context.get(rowTitle)=="env")&lt;/OBJECT&gt;&lt;/MODULE&gt;&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
From Firebug I'm getting the follow errors :-&lt;BR /&gt;
&lt;PRE&gt;&lt;BR /&gt;
the condition threw an exception ReferenceError: rowTitle is not defined     module....min.js (line 2549)&lt;BR /&gt;
&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;The token definitely has value as I use it in the upstream search.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2014 10:08:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Conditional-Switcher-always-picks-first-tree/m-p/118408#M44363</guid>
      <dc:creator>kmugglet</dc:creator>
      <dc:date>2014-04-04T10:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Switcher always picks first tree</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Conditional-Switcher-always-picks-first-tree/m-p/118409#M44364</link>
      <description>&lt;P&gt;Never mind, found it.&lt;BR /&gt;
Double quotes around the token name without dollar signs&lt;BR /&gt;
&lt;PRE&gt;&lt;BR /&gt;
&lt;OBJECT&gt;&lt;PARAM name="condition" /&gt;(context.get("rowTitle")=="env")&lt;BR /&gt;
&lt;/OBJECT&gt;&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;Which looks oddly like your previous answer &lt;BR /&gt;
&lt;A href="http://answers.splunk.com/answers/58424/how-to-pass-a-token-valuedrop-down-value-to-a-conditionalswitcher"&gt;http://answers.splunk.com/answers/58424/how-to-pass-a-token-valuedrop-down-value-to-a-conditionalswitcher&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;SHAME&gt; RTFM &lt;/SHAME&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2014 10:19:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Conditional-Switcher-always-picks-first-tree/m-p/118409#M44364</guid>
      <dc:creator>kmugglet</dc:creator>
      <dc:date>2014-04-04T10:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Switcher always picks first tree</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Conditional-Switcher-always-picks-first-tree/m-p/118410#M44365</link>
      <description>&lt;P&gt;hehe.  yep that's it.  no worries.  ConditionalSwitcher is pretty weird and seldom used. I do recommend spending your cycles getting to know ValueSetter and Switcher better.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2014 16:55:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Conditional-Switcher-always-picks-first-tree/m-p/118410#M44365</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2014-04-04T16:55:00Z</dc:date>
    </item>
  </channel>
</rss>

