Answered my own question - the script below worked for me:
require([
'splunkjs/mvc',
'splunkjs/mvc/simplexml/ready!'
], function(mvc) {
console.log('JavaScript loaded'); // Debug log to confirm script is running
var defaultTokenModel = mvc.Components.getInstance('default');
var submittedTokens = mvc.Components.getInstance('submitted');
document.getElementById('submit_button').addEventListener('click', function() {
var comment = document.getElementById('html_ta_user_comment').value;
console.log('Submit button clicked'); // Debug log to confirm button click
console.log('Comment:', comment); // Debug log to show the comment value
defaultTokenModel.set('tokComment', comment);
console.log('Token set:', defaultTokenModel.get('tokComment')); // Debug log to confirm token is set
// Trigger the search by updating the submitted tokens
submittedTokens.set(defaultTokenModel.toJSON());
});
});
By adding the line submittedTokens.set(defaultTokenModel.toJSON());, we ensured that the search is refreshed whenever the token value changes.
... View more