This is my first attempt using custom JavaScript in a dashboard, and I am not well versed in JavaScript either. So I am hoping this is an easy fix.
I have a token I am setting with messages from the REST calls executed within the JavaScript. The token is being set and I can see the messages in the dashboard. However, if I add a "depends" parameter to the row it is not being displayed when the token is set. How do I get the row to re-render and honor the depends param after the token is set?
XML Snippet:
<row id="errorMessages" depends="$errorMessages$">
<html>
<p>$errorMessages$</p>
</html>
</row>
JavaScript:
require([
"underscore",
"jquery",
"splunkjs/mvc",
"splunkjs/mvc/tableview",
"splunkjs/mvc/simplexml/ready!"
],
function(_, $, mvc, TableView) {
var tokensDefault= mvc.Components.get("default");
$(document).on('click', '#submitButton', function(e) {
e.preventDefault();
var record={"keyType": "nidDetail"};
var keySet=0;
record.nid={};
record.circuit={};
record.misc={};
$('form *').filter(':input').each(function(){
var value = $(this).val();
var field = $(this).attr('name');
var shortField;
if (field === undefined || field === null) {
console.log("Skipping: " + field + " = " + value);
} else if (value === undefined || value === null || value === "") {
console.log("Skipping: " + field + " = " + value);
} else if(field.match(/^nid/)){
shortField=field.replace("nid.","");
record.nid[shortField] = value;
} ...
});
/* Use the request method to send a REST POST request
to the storage/collections/data/{collection}/ endpoint */
serviceDev.get("storage/collections/data/dtsKvStore/" + encodeURIComponent(record._key),{},function(err, response){
if (err){
serviceDev.request(
"storage/collections/data/dtsKvStore",
"POST",
null,
null,
JSON.stringify(record),
{"Content-Type": "application/json"},
function(err, response){
if(err){
tokensDefault.set('errorMessages', "dtsKvStore Update Failed With Following Error: " + err);
} else {
tokensDefault.set('errorMessages', "dtsKvStore Update Succeeded for " + record.nid['hostname']);
}
}
);
}
summaryTableSearch.startSearch();
$('form *').filter(':input').each(function(){
$(this).val('');
});
});
});
}
);
... View more