All Apps and Add-ons

Dynamically Setting default value in the textfield??

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

sideview
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
Get Updates on the Splunk Community!

Splunk Forwarders and Forced Time Based Load Balancing

Splunk customers use universal forwarders to collect and send data to Splunk. A universal forwarder can send ...

NEW! Log Views in Splunk Observability Dashboards Gives Context From a Single Page

Today, Splunk Observability releases log views, a new feature for users to add their logs data from Splunk Log ...

Last Chance to Submit Your Paper For BSides Splunk - Deadline is August 12th!

Hello everyone! Don't wait to submit - The deadline is August 12th! We have truly missed the community so ...