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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...