Dashboards & Visualizations

Use $foo$ token as TextField default value

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

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

Path Finder

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

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

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

Builder

I'm already wrapped in URLLoader.

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

0 Karma

SplunkTrust
SplunkTrust

Try the updated answer.

0 Karma

Builder

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

0 Karma
State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!