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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...