All Apps and Add-ons

How to pass down a parameter from URLLoader to staticFieldsToDisplay in Pulldown module

imrago
Contributor

I am receiving from a Redirector with the help of URLLoader few parameters. One of them I would like to use in the StaticFieldsToDisplay of the Pulldown module, but I can not achieve that.

In the example bellow the pulldown shows : $passdownClicked$ , but on the other hand the HTML component displays the correct value.

<module name="URLLoader" layoutPanel="panel_row1_col1" autoRun="True">
  <module name="ValueSetter">
    <param name="name">passdownClicked</param>
    <param name="value">$clicked$</param>
    <module name="Search">
      <param name="search">index=test $dbs$ | stats count by Server</param>
      <param name="earliest">$earliest$</param>
      <param name="latest">$latest$</param>
      <module name="TimeRangePicker">
    <param name="searchWhenChanged">True</param>
    <module name="Pulldown">
      <param name="name">Server</param>
      <param name="label">Server</param>
      <param name="postProcess">dedup $name$ | sort $name$</param>
      <param name="staticFieldsToDisplay">
        <list>
          <param name="value">$passdownClicked$</param>
          <param name="label">$passdownClicked$</param>
        </list>
      </param>
      <param name="searchFieldsToDisplay">
        <list>
          <param name="value">Server</param>
          <param name="label">Server</param>
        </list>
      </param>
      <param name="template">Server="$value$"</param>
      <module name="Search">
        <module name="HTML">
          <param name="html">The passed down value $passdownClicked$</param>
            </module>
1 Solution

sideview
SplunkTrust
SplunkTrust

OK. So you want to prepopulate the Pulldown using an argument from the URLLoader. No problem.

There's an example in Sideview Utils about this (see the 'linking' section), but I've been meaning to give it some friends and expand on it a bit more. For now you can see the three examples of how that page links to other pages and how the prepopulation works there in the target pages.

The main change you have to make is dont call the argument 'clicked'. I know you're trying to make it simpler but just call it whatever the name of your Pulldown is and you'll be back on the right track. You do not need ValueSetter at all. All you have to do is have a key like 'foo=12' in the URL, URLLoader will make that key value pair available downstream, and if there's a Pulldown or TextField whose name param is 'foo', it will prepopulate.

Some more notes:

  • there is no 'searchWhenChanged' param on ValueSetter.
  • you have to put Search module downstream from all of the Pulldowns/TextFields/Checkbox/SearchBar modules that contribute to it. In your XML you have placed the Search upstream from the Pulldown which isnt what you want. (There is some documentation in sideview utils mentioning this as a key difference between HiddenSearch and Search)
  • You can use $name$ as a shorthand in the 'searchFieldsToDisplay' param, but putting other context keys here is pretty advanced and I doubt it's really what you want -- what you had would look for a field whose name is the value of 'passdownClicked', and it's unlikely such a field name exists.
  • In searchFieldsToDisplay and staticFieldsToDisplay, if value and label are the same you can just specify the value.
  • Its not necessary to specify the $earliest$ and $latest$ in the Search module. I have removed this because the TimeRangePicker module will pick those up from URLLoader automatically.

The end result

<module name="URLLoader" layoutPanel="panel_row1_col1" autoRun="True">
  <module name="TimeRangePicker">

    <!-- this Search just feeds the Pulldown -->
    <module name="Search">
      <param name="search">index=test $dbs$ | stats count by Server</param>

      <module name="Pulldown">
        <param name="name">Server</param>
        <param name="template">Server="$value$"</param>
        <param name="label">Server</param>
        <param name="postProcess">dedup $name$ | sort $name$</param>
        <param name="searchFieldsToDisplay">
          <list>
            <param name="value">$name$</param>
          </list>
        </param>

        <module name="Search">
          <param name="search">index=test $dbs$ $Server$</param>
          <module name="HTML">
            <param name="html">The passed down value is $Server$</param>
          </module>

Again, the main change is that the parameter in the URL should be Server=something, not clicked=something. If for some reason the value has to be different, you could patch it with a ValueSetter to convert the 'clicked' key to a 'Server' key but that would be an extra step. It's way easier to just make the names match up.

I recommend taking another pass reading through the relevant examples in the Sideview Utils docs, and I will make a note to improve the examples here for clarity and completeness.

View solution in original post

sideview
SplunkTrust
SplunkTrust

OK. So you want to prepopulate the Pulldown using an argument from the URLLoader. No problem.

There's an example in Sideview Utils about this (see the 'linking' section), but I've been meaning to give it some friends and expand on it a bit more. For now you can see the three examples of how that page links to other pages and how the prepopulation works there in the target pages.

The main change you have to make is dont call the argument 'clicked'. I know you're trying to make it simpler but just call it whatever the name of your Pulldown is and you'll be back on the right track. You do not need ValueSetter at all. All you have to do is have a key like 'foo=12' in the URL, URLLoader will make that key value pair available downstream, and if there's a Pulldown or TextField whose name param is 'foo', it will prepopulate.

Some more notes:

  • there is no 'searchWhenChanged' param on ValueSetter.
  • you have to put Search module downstream from all of the Pulldowns/TextFields/Checkbox/SearchBar modules that contribute to it. In your XML you have placed the Search upstream from the Pulldown which isnt what you want. (There is some documentation in sideview utils mentioning this as a key difference between HiddenSearch and Search)
  • You can use $name$ as a shorthand in the 'searchFieldsToDisplay' param, but putting other context keys here is pretty advanced and I doubt it's really what you want -- what you had would look for a field whose name is the value of 'passdownClicked', and it's unlikely such a field name exists.
  • In searchFieldsToDisplay and staticFieldsToDisplay, if value and label are the same you can just specify the value.
  • Its not necessary to specify the $earliest$ and $latest$ in the Search module. I have removed this because the TimeRangePicker module will pick those up from URLLoader automatically.

The end result

<module name="URLLoader" layoutPanel="panel_row1_col1" autoRun="True">
  <module name="TimeRangePicker">

    <!-- this Search just feeds the Pulldown -->
    <module name="Search">
      <param name="search">index=test $dbs$ | stats count by Server</param>

      <module name="Pulldown">
        <param name="name">Server</param>
        <param name="template">Server="$value$"</param>
        <param name="label">Server</param>
        <param name="postProcess">dedup $name$ | sort $name$</param>
        <param name="searchFieldsToDisplay">
          <list>
            <param name="value">$name$</param>
          </list>
        </param>

        <module name="Search">
          <param name="search">index=test $dbs$ $Server$</param>
          <module name="HTML">
            <param name="html">The passed down value is $Server$</param>
          </module>

Again, the main change is that the parameter in the URL should be Server=something, not clicked=something. If for some reason the value has to be different, you could patch it with a ValueSetter to convert the 'clicked' key to a 'Server' key but that would be an extra step. It's way easier to just make the names match up.

I recommend taking another pass reading through the relevant examples in the Sideview Utils docs, and I will make a note to improve the examples here for clarity and completeness.

Get Updates on the Splunk Community!

Splunk is Nurturing Tomorrow’s Cybersecurity Leaders Today

Meet Carol Wright. She leads the Splunk Academic Alliance program at Splunk. The Splunk Academic Alliance ...

Part 2: A Guide to Maximizing Splunk IT Service Intelligence

Welcome to the second segment of our guide. In Part 1, we covered the essentials of getting started with ITSI ...

Part 1: A Guide to Maximizing Splunk IT Service Intelligence

As modern IT environments continue to grow in complexity and speed, the ability to efficiently manage and ...