All Apps and Add-ons

Populate checkbox from query string param

redc
Builder

Is there a way to check (or uncheck) a checkbox from a query string parameter, similar to how you can populate pulldown and textfield modules?

I've tried checkboxName=1, checkboxName=on, checkboxName=checked, and checkboxName=onValue.

0 Karma
1 Solution

sideview
SplunkTrust
SplunkTrust

Yes - the name of the query string arg has to match the "name" param of the Checkbox module, and the value of the arg has to match either the "onValue" param or the "offValue" param.

I would just double check that when you tried your ?checkboxName=onValue URL, that the Checkbox module indeed had those exact values in its config, ie:

<param name="name">checkboxName</param>
<param name="onValue">onValue</param>

I thought I remembered something in the release notes in this general area but there isn't anything there, so I'll water that thought down to a general precaution to make sure you're on a current Sideview Utils. Current version is 3.2.1

release notes - http://sideviewapps.com/apps/sideview-utils/release-notes/
mailing list - http://sideviewapps.com/apps/sideview-utils/mailing-list/
everything you wanted to know about Sideview Utils licensing - http://sideviewapps.com/apps/sideview-utils/licensing-faq/

View solution in original post

sideview
SplunkTrust
SplunkTrust

Yes - the name of the query string arg has to match the "name" param of the Checkbox module, and the value of the arg has to match either the "onValue" param or the "offValue" param.

I would just double check that when you tried your ?checkboxName=onValue URL, that the Checkbox module indeed had those exact values in its config, ie:

<param name="name">checkboxName</param>
<param name="onValue">onValue</param>

I thought I remembered something in the release notes in this general area but there isn't anything there, so I'll water that thought down to a general precaution to make sure you're on a current Sideview Utils. Current version is 3.2.1

release notes - http://sideviewapps.com/apps/sideview-utils/release-notes/
mailing list - http://sideviewapps.com/apps/sideview-utils/mailing-list/
everything you wanted to know about Sideview Utils licensing - http://sideviewapps.com/apps/sideview-utils/licensing-faq/

redc
Builder

See, I knew there had to be a less fugly way of doing it! 🙂 Thanks.

0 Karma

sideview
SplunkTrust
SplunkTrust

The far better way, is to 1) Put a URLLoader module into your view, such that it's upstream from all the Pulldown modules. 2) set <param name="keepURLUpdated">True</param>

What that will do, is that every time the user changes a selection in any Sideview form element module on the page, the URL will quietly change up in the location bar. So to restore the exact state of the form later they can just copy the entire URL out and paste it back in later. In addition, the back button and forward buttons on your browser will work to return to previous selected values.

0 Karma

redc
Builder

I tacked this on inside the pulldown module for $foo$:

<module name="Search">
  <param name="search"><![CDATA[index="myindex" $foo$ | dedup bar | table bar | 

stats values(bar) as bar | eval bar=mvjoin(bar, "&foo=")]]>

bar

And then in the HTML module farther down the page:

?foo=$bar$

End result:

?foo=1&foo=2

If there's a better way, PLEASE tell me 'cause this is UGLY: I'm basically running the same search twice, the second time searching for $foo$, which is silly.

0 Karma

redc
Builder

Is it possible to echo out the query string in an HTML panel as you select items from the pulldown? If I echo out the module name, e.g. $foo$, then I get the template value, e.g. ( bar="1" OR bar="2" ). What I want to echo is ?foo=1&foo=2.

I'm doing this as a way for an end user to "bookmark" a specific set of parameters in the pulldown modules so they don't have to re-enter their selections each time; they are not advanced Splunk users and don't have permissions to save searches at this time.

0 Karma

redc
Builder

That works quite nicely, thanks!

0 Karma

sideview
SplunkTrust
SplunkTrust

Nope. If onValue is a $foo$ token, then the comparison will be made to the evaluated value of the foo token and you're back where you started.

You can go the other way though. Make the Checkbox output a simpler token and then use ValueSetter's limited conditional functionality, eg

<module name="Checkbox">
  <param name="name">foo</param>
  <param name="onValue">on</param>      

  <module name="ValueSetter">
    <param name="name">bar</param>
    <param name="if.$foo$=on">something long!</param>
    <param name="default">something else long!</param>
0 Karma

redc
Builder

Yeah, I was afraid of that. My onValue is piping a search to an inputlookup command in order to manipulate data, more than I want to URL-encode into the query string.

Could I set the inputlookup command in a Valuesetter token and make the onValue the $token$ and then just put $token$ in the URL instead? i.e.

<module name="ValueSetter">
  <param name="name">checkboxToken</param>
  <param name="value"><![CDATA[| search NOT [| inputlookup File.csv]]]></param>

And ?checkboxName=$checkboxToken$

Instead of ?checkboxName=| search NOT [etc...]

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, ...