Incident Resolve UI Action

Sam Ogden
Tera Guru

HI All,

I need to make a change to our 'resolve' UI Action on the incident table.

If the log is a parent incident I need it to check that all child incidents are resolved or closed before the parent can be resolved.

I've added the function checkchldinc() to the UI action, but I am not sure how to get this function to run as there is already a function in the onclick field:

find_real_file.png

function resolveIncident(){
//Set the 'Incident state' and 'State' values to 'Resolved', and display
var mim = g_form.getValue('u_major_incident');
var priority = g_form.getValue('priority');
var appStatus = g_form.getValue('u_approval_status');
if (priority != '1' && mim == "true" && appStatus == "Not Yet Approved")
  {
  alert ("As this is a Major Incident MIM has to Approve/Reject to resolve the incident");
}
else{
  g_form.setDisplay('u_pending_type', false);
  g_form.setMandatory('u_pending_type', false);
  g_form.setMandatory('comments', false);
 
  var gdw = new GlideDialogWindow('u_incident_resolution');
  gdw.setTitle('Resolution Details');
  gdw.setPreference('inc_priority', g_form.getValue('priority'));
  gdw.setSize(400,300);
  gdw.render();
}
}

//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
serverResolve();
     

function serverResolve(){
current.incident_state = 6;
current.update();
}

function checkchldinc(){

var chldinc = new GlideRecord('incident');
chldinc.addQuery('parent_incident',current.sys_id);
chldinc.addQuery('active',true);
chldinc.addEncodedQuery('incident_stateIN1,8,9,10');
chldinc.query();
if(chldinc.next())
  {
  gs.addInfoMessage("Please ensure all child incidents are resolved before resolving the parent incident log.");
  current.setAbortAction(true);
  }
}

1 ACCEPTED SOLUTION
9 REPLIES 9

sachin_namjoshi
Kilo Patron
Kilo Patron

You need to call checkchldinc() function in your UI action code like below



function resolveIncident(){



checkchldinc();
//Set the 'Incident state' and 'State' values to 'Resolved', and display
var mim = g_form.getValue('u_major_incident');
var priority = g_form.getValue('priority');
var appStatus = g_form.getValue('u_approval_status');
if (priority != '1' && mim == "true" && appStatus == "Not Yet Approved")
  {
  alert ("As this is a Major Incident MIM has to Approve/Reject to resolve the incident");
}
else{
  g_form.setDisplay('u_pending_type', false);
  g_form.setMandatory('u_pending_type', false);
  g_form.setMandatory('comments', false);
 
  var gdw = new GlideDialogWindow('u_incident_resolution');
  gdw.setTitle('Resolution Details');
  gdw.setPreference('inc_priority', g_form.getValue('priority'));
  gdw.setSize(400,300);
  gdw.render();
}
}


//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
serverResolve();
   


function serverResolve(){
current.incident_state = 6;
current.update();
}


function checkchldinc(){



var chldinc = new GlideRecord('incident');
chldinc.addQuery('parent_incident',current.sys_id);
chldinc.addQuery('active',true);
chldinc.addEncodedQuery('incident_stateIN1,8,9,10');
chldinc.query();
if(chldinc.next())
  {
  gs.addInfoMessage("Please ensure all child incidents are resolved before resolving the parent incident log.");
  current.setAbortAction(true);
  }
}



Regards,


Sachin


Hi Sachin,



Thanks for the above. just added this at the top , but now my UI action is not doing anything?



Thanks



Sam


I believe my query to be correct as I've tried on the filter and it brings back a result:



find_real_file.png


Sam Ogden
Tera Guru

Hi All,



I've got my UI action currently set as below.   I want it to check that any child incidents on the log have been resolved or closed (function checkchldinc)


Currently when I try this UI action nothing happens, not sure where I have gone wrong?



Also is there away to change the addInfoMessage to be an ok or cancel box.   If user selects ok then it proceeds to resolve the incident.   If they select cancel it aborts the UI action?



Any help is greatly appreciated.



Current UI Action Script



function resolveIncident(){
checkchldinc();
//Set the 'Incident state' and 'State' values to 'Resolved', and display
var mim = g_form.getValue('u_major_incident');
var priority = g_form.getValue('priority');
var appStatus = g_form.getValue('u_approval_status');
if (priority != '1' && mim == "true" && appStatus == "Not Yet Approved")
  {
  alert ("As this is a Major Incident MIM has to Approve/Reject to resolve the incident");
}
else{
  g_form.setDisplay('u_pending_type', false);
  g_form.setMandatory('u_pending_type', false);
  g_form.setMandatory('comments', false);
 
  var gdw = new GlideDialogWindow('u_incident_resolution');
  gdw.setTitle('Resolution Details');
  gdw.setPreference('inc_priority', g_form.getValue('priority'));
  gdw.setSize(400,300);
  gdw.render();
}
}


//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
serverResolve();
     


function serverResolve(){
current.incident_state = 6;
current.update();
}


function checkchldinc(){

var chldinc = new GlideRecord('incident');
chldinc.addQuery('parent_incident',current.sys_id);
chldinc.addQuery('active',true);
chldinc.addEncodedQuery('incident_stateIN1,8,9,10');
chldinc.query();
if(chldinc.next())
  {
  gs.addInfoMessage("Please ensure all child incidents are resolved before resolving the parent incident log.");
  current.setAbortAction(true);
  }
}