Dashboards & Visualizations

splunk6 custom HTML visualization not updating if form input changes

mathu
Path Finder

Hi

I've written a custom view in Splunk6 that shows me search results as plain HTML content.
The simple xml view works and shows my html content when the page loads. But if I try to use form inputs such as a dropdown, the view doesn't update when I hit the submit button.

I've basically copy/pasted the examples from Splunk6 custom visualization examples, the code looks as follows:

following code gives me a dropdown with a list of splunk apps:

<fieldset autoRun="true">
   <input type="dropdown" token="app_name" searchWhenChanged="false">
     <label>Select an App:</label>
       <populatingSearch fieldForValue="app" fieldForLabel="app">
         <![CDATA[ | script python splunksvn -v ]]>
       </populatingSearch>
   </input>
[...]
</fieldset>

following code integrates my custom visualization:

    [...]
    <html>
        <h2>local svn diff</h2>
        <div id="htmlcontent-diffsearch"
             class="splunk-manager splunk-searchmanager "
             data-require="splunkjs/mvc/searchmanager"
             data-options='{
                    "app": "subversion",
                    "preview": true,
                    "search": { "type": "token_safe", "value": "| script python splunksvn -c $app_name$}
                }'>
        </div>
        <div id="htmlcontent-diff"
             class="splunk-view"
             data-require="app/subversion/components/htmlcontent/htmlcontent"
             data-options='{
                    "managerid": "htmlcontent-diffsearch"
                 }'>
        </div>
    </html>
    [...]

In my htmlcontent.js file I've basically just implemented the "updateView" function:

    [...]
    updateView: function(viz, data) {
        var myResults = data[0];  // Sets this to the first (and only) row
        this.$el.html(myResults);
    }
    [...]

I suspect that the "html" element in simple xml doesn't know anything about the submit action. But how can I tell my view to update?

Kind regards
mathu

0 Karma
1 Solution

mathu
Path Finder

Using double dollar signs for the token in the search string helped...

changing:

"search": { "type": "token_safe", "value": "| script python splunksvn -c $app_name$ }

to:

"search": { "type": "token_safe", "value": "| script python splunksvn -c $$app_name$$ }

View solution in original post

ppohar
Explorer

Thanks, this worked for me.

0 Karma

mathu
Path Finder

Using double dollar signs for the token in the search string helped...

changing:

"search": { "type": "token_safe", "value": "| script python splunksvn -c $app_name$ }

to:

"search": { "type": "token_safe", "value": "| script python splunksvn -c $$app_name$$ }

dominiquevocat
SplunkTrust
SplunkTrust

I do have the same issue (my impression) as the question asker and when i try this trick with the double $ then i will never ever get a result :-=)

0 Karma

yplambert
New Member

Are you aware that your "value": "| script... doesn't have a closing quotation mark? Could that be the problem, or is it just a copy/paste artifact?

0 Karma

MattZerfas
Communicator

This worked for me thanks!

0 Karma

mathu
Path Finder

.. by the way, the code works with all ohter elements (such as table, chart, single). "html" seems to be the only element not reacting on form changes

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...