All Apps and Add-ons

Help with ValueSetter

zzczar
New Member

I am looking for some help with using a search result value to set a $foo$ token value.

I have a search result that will return a value, field1, that I would like to pass to other views as a $foo$ token.

I am able to reference and display this field within the current view:

<module name="HTML" layoutPanel="panel_row1_col1">
  <param name="html">
    Value of field1: $results[0].field1$
  </param>
</module>

However, I am not able to get this value inside the ValueSetter module.

<module name="ValueSetter">
  <param name="urlEncodeKeys">field1</param>
  <param name="name">url_encoded_keys</param>
  <param name="value">field1=$results[0].field1$</param>
  <module name="HTML" layoutPanel="panel_row2_col1">
    <param name="html">
      Go to &lt;a href="tmp_target1?$url_encoded_keys$"&gt;Target 1&lt;/a&gt;.&lt;br&gt;
      &lt;br&gt;
      Go to &lt;a href="tmp_target2?$url_encoded_keys$"&gt;Target 2&lt;/a&gt;.&lt;br&gt;
    </param>
  </module>
</module>

This url ends up: ..\tmp_target1?field1=

I tried to use $results[0].field.rawValue$, but this did not help.

Is there a better way (or any way) to accomplish this?

I appreciate any help or guidance.

Thanks

0 Karma
1 Solution

sideview
SplunkTrust
SplunkTrust

What you're looking for, is the ResultsValueSetter module. Which is a strange little module that can basically reach into the search results, pull one or more field values out of the first row of those results, and make those field values available as straight-up $fieldName$ tokens downstream.

Note that the $results[0].fieldName$ syntax that you're using is a syntax that is only within the HTML module. That syntax is not supported anywhere outside the HTML module.

Anyway, here's what you need. You still need the ValueSetter to urlEncode the key, but now the ResultsValueSetter will make your field available to it, simply as $field1$.

<module name="ResultsValueSetter">
  <param name="fields">field1</param>

  <module name="ValueSetter">
    <param name="name">url_encoded_keys</param>
    <param name="value">field1=$field1$</param>
    <param name="urlEncodeKeys">field1</param>

    <module name="HTML" layoutPanel="panel_row2_col1">
      <param name="html">
        Go to &lt;a href="tmp_target1?$url_encoded_keys$"&gt;Target 1&lt;/a&gt;.&lt;br&gt;
        &lt;br&gt;
        Go to &lt;a href="tmp_target2?$url_encoded_keys$"&gt;Target 2&lt;/a&gt;.&lt;br&gt;
      </param>
    </module>
  </module>
 </module>

Also I'm sorry for the delay answering. If you add the 'Sideview Utils' app tag, then i get a little notification, or just contact me directly. If you post here without the tag then I don't see it until I go on big sweeps to catch unanswered questions (like now)

View solution in original post

sideview
SplunkTrust
SplunkTrust

What you're looking for, is the ResultsValueSetter module. Which is a strange little module that can basically reach into the search results, pull one or more field values out of the first row of those results, and make those field values available as straight-up $fieldName$ tokens downstream.

Note that the $results[0].fieldName$ syntax that you're using is a syntax that is only within the HTML module. That syntax is not supported anywhere outside the HTML module.

Anyway, here's what you need. You still need the ValueSetter to urlEncode the key, but now the ResultsValueSetter will make your field available to it, simply as $field1$.

<module name="ResultsValueSetter">
  <param name="fields">field1</param>

  <module name="ValueSetter">
    <param name="name">url_encoded_keys</param>
    <param name="value">field1=$field1$</param>
    <param name="urlEncodeKeys">field1</param>

    <module name="HTML" layoutPanel="panel_row2_col1">
      <param name="html">
        Go to &lt;a href="tmp_target1?$url_encoded_keys$"&gt;Target 1&lt;/a&gt;.&lt;br&gt;
        &lt;br&gt;
        Go to &lt;a href="tmp_target2?$url_encoded_keys$"&gt;Target 2&lt;/a&gt;.&lt;br&gt;
      </param>
    </module>
  </module>
 </module>

Also I'm sorry for the delay answering. If you add the 'Sideview Utils' app tag, then i get a little notification, or just contact me directly. If you post here without the tag then I don't see it until I go on big sweeps to catch unanswered questions (like now)

zzczar
New Member

Nick,

Perfect! Exactly what I needed. Many thanks.

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...