@alwayslearning you are possibly looking for the following JS. I would recommend you to search in the Splunk Web Reference Documentation on Splunk Dev site for each of the SplunkJS stack elements mentioned in the code to understand them better. require([
'underscore',
'jquery',
'splunkjs/mvc',
'splunkjs/mvc/simplexml/ready!'
], function (_, $, mvc) {
// Iitialize Default and Submitted Token Model.
var defaultTokenModel = mvc.Components.get("default");
var submittedTokenModel = mvc.Components.get("submitted");
// #html_ta_user_comment button Clicked
$(document).on("click", "input#html_ta_user_comment", function (e) {
// Capture value of the Text Area
var str_ta_investigateoutcome = $("textarea#ta_investigateoutcome").val();
// If text area value is not null or empty then set token $investigateoutcome$ value
if(str_ta_investigateoutcome!== undefined && str_ta_investigateoutcome!==""){
// Default Token Model update For token value in UI
defaultTokenModel.set("investigateoutcome", str_ta_investigateoutcome);
// Submitted Token Model update For running searches on Dashboard with Submit Button.
submittedTokenModel.set("investigateoutcome", str_ta_investigateoutcome);
}else{
// If Text Area is not populated before clicking on the #html_ta_user_comment button pop-up alert!
alert("Please add comment before submitting!");
}
});
});
... View more