@niketnilay, thank you for your reply.
I tested your suggestion, however it is not working.
The two "console.log(alertid);" and "console.log(filename);" before search execution output are correct, but "Search started" or "search:done" status is not shown.
Please find the my complete JS code follows:
require([
"splunkjs/mvc",
"splunkjs/mvc/searchmanager",
"splunkjs/mvc/simplexml/ready!"
], function(mvc) {
var SearchManager = require("splunkjs/mvc/searchmanager");
// Get the Events table
var myEventsTable = mvc.Components.get('myevents');
// Respond to a click event
myEventsTable.on("click", function(e) {
// Get the default model
var tokens = mvc.Components.get("default");
var alertid= tokens.get("src_type_tok");
var ctime = new Date().getTime();
// create file and path var
var filename = ctime + "_" + alertid + ".png";
console.log(alertid);
console.log(filename);
var search = new SearchManager({
"id": "search_img",
"earliest_time": "-5m@m",
"latest_time": "now",
"search": "| imgsearch $alertid$ $filename$", // this one not working
//"search": "| imgsearch 3215687 153857376_3215687.png", // this is working fine
"cancelOnUnload": true,
"autostart": false,
"auto_cancel": 90,
"preview": false,
"cache": false,
"tokenDependencies": {
},
"runWhenTimeIsUndefined": false
}, {tokens: true, tokenNamespace: "submitted"});
console.log("after search function");
search.on('search:failed', function() {
console.log("Search failed");
}.bind(this));
search.on("search:start", function() {
console.log("Search started");
}.bind(this));
search.on("search:done", function() {
console.log("Search completed");
}.bind(this));
// Start the search
search.startSearch();
});
});
... View more