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
Revered Legend

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
Revered Legend

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
Revered Legend

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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...