Dashboards & Visualizations

From one Button i am looking to launch a URL and reset a token

robertlynch2020
Influencer

HI - From one button. I am looking to launch a URL (working) and reset a token "comment_token" to * with javascript (not working).. any help would be wonderful, please.

robertlynch2020_0-1636103967463.png

 

<form theme="dark" script="someJsCode.js">
      <input type="text" token="comment_token" searchWhenChanged="true">
        <label>Comment</label>
        <default>*</default>
        <initialValue>*</initialValue>
      </input>
      <html>
                 <style>.btn-primary { margin: 5px 10px 5px 0; }</style>
                 <a href="http://$mte_machine$:4444/executeScript/envMonitoring@@qcst_processingScriptsChecks.sh/-updateComment/$runid_token$/$script_token$/$npid_token$/%22$comment_token$%22" id="buttonId" target="_blank" class="btn btn-primary" style="height:25px;width:250px;">Submit</a>
             </html>

 

 

Java script

require([
        'jquery',
        'splunkjs/mvc',
        'splunkjs/mvc/simplexml/ready!'
    ], function ($, mvc) {
    var tokens = mvc.Components.get("default");
    $('#buttonId').on("click", function (e){
        tokens.set("form.comment_token", "*");
    });
});

 

robertlynch2020_1-1636104054796.png

I think its this line - tokens.set("form.comment_token", "*"); but i cant be sure 

robertlynch2020_2-1636104062296.png

 

Labels (1)
Tags (1)
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@robertlynch2020 

 

Can you please try this?

 

<html>
                 <style>.btn-primary { margin: 5px 10px 5px 0; }</style>
                 <div class="btn btn-primary" id="buttonId">
                   Submit
                 </div>
             </html>

 

JS

require([
    'jquery',
    'splunkjs/mvc',
    'splunkjs/mvc/simplexml/ready!'
], function($, mvc) {
    var submittedTokenModel = mvc.Components.get("submitted");
    var defaultTokenModel = mvc.Components.get('default');
    var utils = require("splunkjs/mvc/utils");
    $(document).ready(function() {
        
        $('#buttonId').on("click", function(e) {
            
            var mte_machine = defaultTokenModel.get("mte_machine");
            var runid_token = defaultTokenModel.get("runid_token");
            var script_token = defaultTokenModel.get("script_token");
            var npid_token = defaultTokenModel.get("npid_token");
            var comment_token = defaultTokenModel.get("comment_token");
            utils.redirect("http://" + mte_machine + ":4444/executeScript/envMonitoring@@qcst_processingScriptsChecks.sh/-updateComment/" + runid_token + "/" + script_token + "/" + npid_token + "/%22" + comment_token + "%22", "_blank");
            
            defaultTokenModel.set("form.comment_token", "*");
            submittedTokenModel.set(defaultTokenModel.toJSON());
            
        });
    });
});

 

I hope this will help you.

Thanks
KV
▄︻̷̿┻̿═━一   😉

If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...