All Apps and Add-ons

How can I hide content on my view until a search runs?

Super Champion

I noticed that some stuff doesn't show up on your view until after the search has been started. For example, the ViewRedirectorLink module doesn't show the "View results" link until the search has been kicked off. Is it possible to do this with other modules too?

I'm specifically trying to hide some text in an HTML module (which is part of the Sideview Utils app). I'd like it to only show up after the search starts.

I'm looking for something fairly simple, if at all possible.


I'm afraid there's nothing that will be fairly easy, except for people who have a very good understanding of how the module framework methods work. Since these methods are only just beginning to have public documentation, I'm afraid there's not a lot of those people. Nonetheless, by reading the new docs and digging through the source code, it's certainly possible to become one of them and many have.

But this is the sort of thing I use what Sideview Utils calls a "custom behavior" for. In Sideview Utils there is a CustomBehavior module, and there is also a customBehavior param on every module. The former is safe to use if you know the basic methods of AbstractModule somewhat well. The latter is only safe to use if you know the specific Sideview module's methods very well.

The docs for custom behaviors are somewhat hidden but you can find a link to them on the 'Tools' page in Sideview Utils. However again, the key prerequisite for success concerns the workings of the module framework methods.

But pressing on, the simplest way I can think of is to nest your HTML module inside a CustomBehavior module, give that CustomBehavior module a 'customBehavior' param value of "onlyShowAfterSearchStarts", and then put the following code into application.js. Whether that's simple enough to be worth using, I dont know - It's certainly up to you.

// avoid throwing exceptions on views that dont have the SideviewUtils module.
if (typeof(Sideview)!="undefined") {
    // need to wait for all the modules to be initialized before we do it.
    $(document).bind("allModulesInitialized",function() {
        // iterates through all modules that specify the given custom behavior.
        Sideview.utils.forEachModuleWithCustomBehavior("onlyShowAfterSearchStarts", function(i,customBehaviorModule) {
            // modules can be shown or hidden by more than one piece of logic. 
            // in the end they are only actually shown if all the 'reasons' say they 
            // can be shown.  This is done by always passing args to show/hide methods.
            var ourReason = "onlyWhenSearchRunning"
            customBehaviorModule.onContextChange = function() {
            // hide it again when something dispatches the next search.
            customBehaviorModule.onBeforeJobDispatched = function() {

Super Champion

Doh! I needed a splunkweb restart. ( Now "application.js" is loading, but it doesn't appear to be doing anything. I actually found different workaround that suites my needs; so I'm just going to assume that I'm doing something wrong and just walk away from this for now. (All the warnings with the custom behavior docs have scared me off.) Thanks for your help.

0 Karma

Super Champion

I'm having some trouble getting this to work; because "application.js" isn't being loaded by my view. Do I have to do something special to get that script to load?

0 Karma
Get Updates on the Splunk Community!

The Splunk Success Framework: Your Guide to Successful Splunk Implementations

Splunk Lantern is a customer success center that provides advice from Splunk experts on valuable data ...

Splunk Training for All: Meet Aspiring Cybersecurity Analyst, Marc Alicea

Splunk Education believes in the value of training and certification in today’s rapidly-changing data-driven ...

Investigate Security and Threat Detection with VirusTotal and Splunk Integration

As security threats and their complexities surge, security analysts deal with increased challenges and ...