Dashboards & Visualizations

Using URL parameters to set input. Conditions with match not setting tokens.

RobKelley06
Explorer

I have a link on one dashboard 

 

    <html>
      <a href="....._dashboard?form.dcCell=$dcCell$&amp;form.rhel=$rhel$&amp;form.field1.earliest=$field1.earliest$&amp;form.field1.latest=$field1.latest$">PRD Dashboard</a>
       </html>

The link is filling out correctly.  When I click it and go to the target dashboard, the inputs are being set correctly, but the tokens are not being set at all.

Target dashboard

  <fieldset submitButton="false" autoRun="true">
    <input type="dropdown" token="rhel" searchWhenChanged="true">
      <label>RHEL Server</label>
      <choice value="rhel6">RHEL 6</choice>
      <choice value="rhel8">RHEL 8</choice>
      <change>
        <condition match="match($rhel$,&quot;rhel6&quot;) AND match($dcCell$, &quot;allE&quot;)">
          <set token="use_jcs">True</set>
          <set token="use_hikari">True</set>
        </condition>
<condition match="match($rhel$,&quot;rhel8&quot;) AND match($dcCell$, &quot;allE&quot;)">
          <set token="use_hikari">True</set>
          <unset token="use_jcs"></unset>

 

When using the drop downs, everything works fine.  It's only when i try to put the parameters in the url, does it break.  I have even tried using the drop downs and the copying the url it generates on the browser and going directly to that.   It still does not set the tokens.  What am I missing?

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try using token modifiers

    <html>
      <a href="....._dashboard?form.dcCell=$dcCell|n$&amp;form.rhel=$rhel|n$&amp;form.field1.earliest=$field1.earliest|n$&amp;form.field1.latest=$field1.latest|n$">PRD Dashboard</a>
       </html>
0 Karma

RobKelley06
Explorer

The URL is not the issue.  It's the target dashboard not determining the tokens.  I have used the exact URL that changing the dropdowns produces in the browser URL and it still doesn't work.  I know the URL works correctly because the dropdowns are changing based off of the URL, but the tokens inside the "condition" statements are not being calculated.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

It looks like the change handler for the dropdown is not triggered when the dashboard loads. You could try using a hidden text input to relay the change.

<form>
  <label>Token setter</label>
  <description>Inputs to set multi-select tokens</description>
  <fieldset submitButton="false" autoRun="true">
    <input type="multiselect" token="preselect" searchWhenChanged="true">
      <label>Select</label>
      <choice value="W">w</choice>
      <choice value="X">x</choice>
      <choice value="Y">y</choice>
      <choice value="Z">z</choice>
      <default>X</default>
      <change>
        <condition match="match($preselect$,&quot;[XYZ]&quot;)">
          <eval token="gettoken">"form.inbound=".mvjoin(split(preselect," "),"&amp;form.inbound=")</eval>
        </condition>
      </change>
    </input>
  <html>
    <a target="_blank" href="/app/answers/token_getter?$gettoken|n$">Go to getter</a>
  </html>
  </fieldset>
</form>
<form>
  <label>Token getter</label>
  <description>Multi-select initialised on call</description>
  <fieldset submitButton="false" autoRun="true">
    <input type="multiselect" token="preselect" searchWhenChanged="true">
      <label>Pre-select</label>
      <choice value="W">w</choice>
      <choice value="X">x</choice>
      <choice value="Y">y</choice>
      <choice value="Z">z</choice>
      <default>X</default>
      <change>
        <condition match="match($preselect$,&quot;[XYZ]&quot;)">
          <set token="changedtoken">$value$</set>
        </condition>
      </change>
    </input>
    <html>
      <p>Changed token now $changedtoken$</p>
    </html>
    <input type="text" token="inbound" searchWhenChanged="true" depends="$alwayshide$">
      <label>Received token</label>
      <change>
        <set token="form.preselect">$value$</set>
      </change>
    </input>
  </fieldset>
</form>

You might have to something a bit more fancy for multi-selects

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

From Data to Insight: Announcing the Winners of the Splunk Dashboard Contest

Hi Splunkers, First off, thank you to everyone who participated in our very first From Data to Insight: The ...

Splunk Developers: Construct Your Future at the .conf26 Builder Bar

Calling all Splunk architects, platform admins, and app developers: the site is open, and the blueprints are ...

Quick connection discovery mode for forwarders

When a Splunk forwarder loses connectivity to its indexers, it does not always reconnect immediately. In many ...