All Apps and Add-ons
Highlighted

Dynamically Setting default value in the textfield??

Path Finder

Hi All,

I want to set the default value for a Textfield dynamically. like for example i select particular device in dashboard1, this device has some 8 parameters so when i select a particular device and click "view parameter details" button, i want it to send default values for those parameters to dashboard2. And these default values should get changed on different device selection.
How can i do this? any idea?

Thanks in advance.

Highlighted

Re: Dynamically Setting default value in the textfield??

SplunkTrust
SplunkTrust

Probably the best way is to use the ValueSetter module's conditional abilities. This stuff is deliberately limited but it comes in handy often.

So right now you have a TextField on dashboard2. Let's say its name param is "myTextField". You want to pass the default value based on the upstream value of $myPulldown$. Last but not least you have a Redirector on dashboard1. and say that Redirector looks like this:

<module name="Redirector">
  <param name="url">dashboard2</param>
  <param name="myTextField">   ???   </param>
  <param name="arg.earliest">$search.timeRange.earliest$</param>
  <param name="arg.latest">$search.timeRange.latest$</param>
</module>

So you can sneak a ValueSetter into this picture like so. Again the logic is very limited and here because you're setting multiple cases you have to give each one a priority flag. But still... it does what you need with no custom code.

<module name="ValueSetter">
  <param name="name">dynamicTextFieldValue</param>
  <param name="if.$myPulldown.rawValue$=someValue[priority=1]">firstTextFieldValue</param>
  <param name="if.$myPulldown.rawValue$=someOtherValue[priority=2]">secondTextFieldValue</param>
  <param name="default">defaultTextFieldValue</param>

  <module name="Redirector">
    <param name="url">dashboard2</param>
    <param name="myTextField">$dynamicTextFieldValue$</param>
    <param name="arg.earliest">$search.timeRange.earliest$</param>
    <param name="arg.latest">$search.timeRange.latest$</param>
  </module>
</module>

2) A totally different way to do it, is to use a different ValueSetter trick with the Pulldown itself, to get multiple values coming out of the Pulldown directly. This has been covered in a number of other questions so I'll just link to a good one. http://answers.splunk.com/answers/91244/pulldown-module-statically-setting-two-values-per-pulldown-o...

3) Last but not least you could use some custom code. I always see this as a last resort, but you can use a CustomBehavior module and implement the getModifiedContext method. In that method look at the upstream value of the pulldown key, set whatever keys you need, then return the modified context instance.

0 Karma