Dashboards & Visualizations

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

RobKelley06
Path Finder

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
Path Finder

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
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...