Hi All,
Please check below xml code of my dashboard. I'm using a javascript in backend for some operation.
I want to capture the job.sid of the searchtemplate in dashboard in the javascript.
I tried with setting a token in dashboard with $job.sid$ and reading it from javascript.
I tried to put the set token parameter at multiple location on dashboard but it return undefined in javascript.
Dashboard XML
NMG Command Search - IN CCS
<![CDATA[
| datamodel nmg_cm_datamodel_in_ccs nmg_cm_dm_in_ccs search | rename nmg_cm_dm_in_ccs.parameter AS Parameter | rename nmg_cm_dm_in_ccs.terminal AS Terminal | rename nmg_cm_dm_in_ccs.command AS "Command" | search nmg_cm_dm_in_ccs.element_id="$input_element_id$" Command="$input_command$" nmg_cm_dm_in_ccs.user_id="$input_user_id$" $dangerous$ $changecommand$ $input_freeform$ | rename nmg_cm_dm_in_ccs.element_id AS "Element ID" | rename nmg_cm_dm_in_ccs.user_id AS "User"| rename nmg_cm_dm_in_ccs.task_status AS "Task Status"| rename nmg_cm_dm_in_ccs.dangerous AS Dangerous| eval s_earliest=_time | eval s_latest=_time+1 | table _time, "Element ID","User","Command",Parameter, "Task Status", Dangerous, Terminal, s_earliest, s_latest
]]>
$job.sid$
$job.sid$
Element ID
Command
User ID
Dangerous Commands
Show All Commands
<choice value="nmg_cm_dm_in_ccs.dangerous_level=">Show All Commands
All Dangerous Commands
Unknown Commands
Critical
High
Medium
Technical Query
Unknown, Critical, High and Medium
Change Commands
Show All Commands
Show All Commands
Only Change Commands
Search
Yesterday
Click the 'Validate' button once review is completed.
$earliest$
$latest$
Commands
true
50
<![CDATA[ /app/view_ccs_cm/search?earliest=$row.s_earliest$&latest=$row.s_latest$&q=%7C%20datamodel%20nmg_cm_datamodel_in_ccs%20nmg_cm_dm_in_ccs%20search%7Csearch%20nmg_cm_dm_in_ccs.command=$row.Command$
]]>
javascript
require(["jquery", "splunkjs/mvc", "splunkjs/ready!", "splunkjs/mvc/simplexml/ready!"],
function($ , mvc) {
$("#btn-submit").on("click", function (){
var user = $C.USERNAME;
var report = "CCS Reports";
var tokens = mvc.Components.get('default');
var tokenValue = tokens.get('JobSid');
alert(tokenValue);
/*var validation = $.ajax({
type: "POST",
url: "https://host:8000/en-US/custom/view_ccs_cm/test_script/my_function?user_name="+user+"&report_name="+report,
data: "user_name="+user+"&report_name="+report,
success : function(data){
alert(data);
}
});*/
});
}
);
... View more