Dashboards & Visualizations

Use $foo$ token as TextField default value

redc
Builder

I'm attempting to set a default value for a TextField module using a token that is defined upstream. When I use the token in the default param, though, it prints out the literal token.

My code:

<module name="ValueSetter">
  <param name="name">foo</param>
  <param name="value">Foo Bar</param>
  <module name="TextField" LayoutPanel="panel_row5_col1">
    <param name="float">left</param>
    <param name="name">from</param>
    <param name="default">$foo$</param>

Expected result displayed in text field as default value: Foo Bar

Actual result: $foo$

I've seen mention in other threads that the TextField module may or may not accept a token in its default value; apparently, mine is not accepting it. How do I make it do this?

(Note: I do not want this passed in from a URL query string parameter!)

Tags (3)
0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Try this (have the name of the TextField same as variable define upstream)

Update:
This seems to work for me.

<view autoCancelInterval="90" isPersistable="true" isSticky="true" isVisible="true" objectMode="SimpleForm" onunloadCancelJobs="true" template="dashboard.html">
  <label>Test TextField</label>
  <!-- Start Application Header -->
  <module name="AccountBar" layoutPanel="appHeader" />
  <module name="AppBar" layoutPanel="navigationHeader" />
  <module name="SideviewUtils" layoutPanel="appHeader" />
  <module name="Message" layoutPanel="messaging">
    <param name="filter">*</param>
    <param name="clearOnJobDispatch">False</param>
    <param name="maxSize">1</param>
  </module>
  <!--Message-->
  <module name="Message" layoutPanel="messaging">
    <param name="filter">splunk.search.job</param>
    <param name="clearOnJobDispatch">True</param>
    <param name="maxSize">1</param>
  </module>
  <!--Message-->
  <!-- End Application Header -->
  <module name="URLLoader" layoutPanel="viewHeader" autoRun="True">
         <module name="ValueSetter">            
            <param name="name">foo</param>
            <param name="value">Random text</param>
            <module name="TextField" LayoutPanel="panel_row1_col1">
            <param name="float">left</param>
            <param name="name">foo</param>
            <param name="label">from:</param>
                <param name="default">*</param>
              </module>
          </module> 
  </module>
</view>

View solution in original post

0 Karma

ifeldshteyn
Communicator

How would one define a dynamically generated token. In the above example you define a static one, but what about one that arrives from upstream dynamically. I've tried replacing "Random text" with $dynamic_string$ and ValueSetter didn't like that.

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Try this (have the name of the TextField same as variable define upstream)

Update:
This seems to work for me.

<view autoCancelInterval="90" isPersistable="true" isSticky="true" isVisible="true" objectMode="SimpleForm" onunloadCancelJobs="true" template="dashboard.html">
  <label>Test TextField</label>
  <!-- Start Application Header -->
  <module name="AccountBar" layoutPanel="appHeader" />
  <module name="AppBar" layoutPanel="navigationHeader" />
  <module name="SideviewUtils" layoutPanel="appHeader" />
  <module name="Message" layoutPanel="messaging">
    <param name="filter">*</param>
    <param name="clearOnJobDispatch">False</param>
    <param name="maxSize">1</param>
  </module>
  <!--Message-->
  <module name="Message" layoutPanel="messaging">
    <param name="filter">splunk.search.job</param>
    <param name="clearOnJobDispatch">True</param>
    <param name="maxSize">1</param>
  </module>
  <!--Message-->
  <!-- End Application Header -->
  <module name="URLLoader" layoutPanel="viewHeader" autoRun="True">
         <module name="ValueSetter">            
            <param name="name">foo</param>
            <param name="value">Random text</param>
            <module name="TextField" LayoutPanel="panel_row1_col1">
            <param name="float">left</param>
            <param name="name">foo</param>
            <param name="label">from:</param>
                <param name="default">*</param>
              </module>
          </module> 
  </module>
</view>
0 Karma

redc
Builder

Ran across this need again and figured out what the problem with your answer is: You should not add the <param name="default"></param> param to the TextField module. Then it will use the upstream value as the default (otherwise it'll use "" instead of "Random text").

Could you update that in your answer for anyone else who stumbles across this post?

Thanks!

0 Karma

redc
Builder

I'm already wrapped in URLLoader.

Using your example, it outputs * instead of Random text inside the text input.

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Try the updated answer.

0 Karma

redc
Builder

Still outputs $foo$ instead of Foo Bar. (Actually, your exact code outputs * instead of Foo Bar.)

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...