All Apps and Add-ons

pass $foo$ value to textfield default

sbsbb
Builder

![alt text][1]I have an Urlloader, and I'm unable to pass $foo$ value to the default value of a text field (I don't want a pulldown, because the user must be able to enter a value if nothing is coming from the url)

1 Solution

sideview
SplunkTrust
SplunkTrust

Assuming that you have a URL with something like ?username=fred in it, and you want to prepopulate the TextField for usernames to the value of "fred", there are only a few ingredients for success here:

1) The "name" param on the TextField has to exactly match the querystring argument in the URL.
2) The TextField module has to be downstream from the URLLoader (read the framework intro page if you don't know what this means)

As far as the page doing the redirect, 95% of the time you'll be using a Redirector module, and if Redirector is passing along the selected value from a Pulldown/TextField/Checkbox/Radio/Tabs/Table/Chart, make sure it's passing $foo.rawValue$ and not just $foo$. The rawValue version of the key won't be backslash escaped and that's the version you want up in the URL.

UPDATE: The problem is simply that your name param on your TextField, and the value you have in the URL does not match. Much like Splunk field names in search results, $foo$ tokens in the Splunk UI are always case-sensitive. What you have here has FahrtBezeichner as the name param of your TextField, and based on the debugging you're doing, you have fahrtBezeichner in the URL. Note the lower-case f vs upper-case F is all that it takes for these names to not match at all. Change one or the other so that they match and it will all work the way you expect.

Additionally, remove this line from your TextField module:

<param name="default">$fahrtbezeichner$</param>

I assume you added this at a later phase thinking it might help. However you'll have to remove it, and with that line completely gone, it'll have the behavior you want automatically anyway.

View solution in original post

sideview
SplunkTrust
SplunkTrust

Assuming that you have a URL with something like ?username=fred in it, and you want to prepopulate the TextField for usernames to the value of "fred", there are only a few ingredients for success here:

1) The "name" param on the TextField has to exactly match the querystring argument in the URL.
2) The TextField module has to be downstream from the URLLoader (read the framework intro page if you don't know what this means)

As far as the page doing the redirect, 95% of the time you'll be using a Redirector module, and if Redirector is passing along the selected value from a Pulldown/TextField/Checkbox/Radio/Tabs/Table/Chart, make sure it's passing $foo.rawValue$ and not just $foo$. The rawValue version of the key won't be backslash escaped and that's the version you want up in the URL.

UPDATE: The problem is simply that your name param on your TextField, and the value you have in the URL does not match. Much like Splunk field names in search results, $foo$ tokens in the Splunk UI are always case-sensitive. What you have here has FahrtBezeichner as the name param of your TextField, and based on the debugging you're doing, you have fahrtBezeichner in the URL. Note the lower-case f vs upper-case F is all that it takes for these names to not match at all. Change one or the other so that they match and it will all work the way you expect.

Additionally, remove this line from your TextField module:

<param name="default">$fahrtbezeichner$</param>

I assume you added this at a later phase thinking it might help. However you'll have to remove it, and with that line completely gone, it'll have the behavior you want automatically anyway.

sbsbb
Builder

I've understood, it was not clear to me, that the input is taking automatically the value from the URL Variable if it has the same name.

0 Karma

sideview
SplunkTrust
SplunkTrust

Yes. you have to

1) resolve the casing issue
2) delete the <param name="default">$fahrtbezeichner$</param>, because it is unnecessary and it will get in the way.
3) I'm afraid you cannot create group attributes dynamically with $foo$ tokens.

0 Karma

sbsbb
Builder

Even by changing this, it doesn't work .

I've also similar pb on a groupName from a table, and when I make a copy/paste from the variableName in a html module, it works...(and I see them in Debugmode)

Is it possible that default value, and groupname can't be set with a $foo$, or maybe for groupName, that it can't be set after the page is loaded ? (my groupName is set from a postProcess)

I've posted that code in the description...

0 Karma

sideview
SplunkTrust
SplunkTrust

thanks for posting XML. Indeed the problem was simply that your name param did not match the variable you were passing in the URL. Note that $foo$ tokens are always case-sensitive and you had a capital "F" in one, and a lowercase "f" in the other.

0 Karma

sbsbb
Builder

Here are the information, thx.

0 Karma

sideview
SplunkTrust
SplunkTrust

I only mention the Redirector module because that's where the URL's generally come from. 😃 But if you're just making links manually in HTML modules or embedding them into the app navigation, then yea you won't need to think about Redirector.

Can you send me the XML for the whole view? Incidentally what is the name param value?

0 Karma

sbsbb
Builder
  1. The name is correct, and foo variable is working correctly in html module (see description)
  2. it is downstream , not directly

$foo$ is working on the html module... but not on textfield

I'm not sure to understand why the redirected is needed and how it works ?

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

Splunk is officially part of Cisco

Revolutionizing how our customers build resilience across their entire digital footprint.   Splunk ...

Splunk APM & RUM | Planned Maintenance March 26 - March 28, 2024

There will be planned maintenance for Splunk APM and RUM between March 26, 2024 and March 28, 2024 as ...