- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2015 03:15 AM
Good morning all.
I have a rather urgent plea for some assistance as I appear to have inherited a UI Action which does not appear to be working as expected. On click it should resolve any child incident, inserting predetermined comments. However it appears to be closing other (non-child) INCs. Below is the script in it's current form. Am I right to say the issue is most likely with this part from row 10?
var incident = new GlideRecord("incident");
incident.addQuery("current.parent_incident", "=", current.sys_id);
incident.addQuery("incident_state", "!=", "6");
incident.addQuery("incident_state", "!=", "7");
incident.query(
function onSubmit_ResolveChild() {
var response = confirm('Resolve all child records?');
if (!response)
return false;
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'resolvechild'); //MUST call the 'Action name' set in this UI Action
}
var incident = new GlideRecord("incident");
incident.addQuery("current.parent_incident", "=", current.sys_id);
incident.addQuery("incident_state", "!=", "6");
incident.addQuery("incident_state", "!=", "7");
incident.query();
while (incident.next()) {
incident.incident_state.setValue(6);
incident.active.setValue(false);
incident.close_code = current.close_code;
if (incident.close_notes.nil()) {
msg = "Resolution notes copied from Parent Incident";
if (current.close_notes.toString().indexOf(msg) == 0)
incident.close_notes = current.close_notes;
else
incident.close_notes = msg + ": " + current.close_notes;
}
if (current.u_customer_visible_resolution_.nil()) {
msg = "We believe your issue was connected to a wider issue which has now been resolved, if this is not the case for yourself please contact the IT Service Desk.";
incident.u_customer_visible_resolution_ = msg;
}
else
{
incident.u_customer_visible_resolution_ = current.u_customer_visible_resolution_;
}
incident.update();
gs.print("Incident " + incident.number + ' resolved based on resolution of Parent Incident '+current.number);
}
gs.addInfoMessage("All child incidents have been resolved");
action.setRedirectURL(current);
action.setReturnURL(current);
Onclick: onSubmit_ResolveChild();
Condition of UI Action: Condtion: current.child_incidents != 0 && current.incident_state == 6 || current.incident_state == 7 && gs.hasRole("itil")
Many thanks in advance guys.
Daniel
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2015 05:09 AM
Replace
- incident.addQuery("current.parent_incident", "=", current.sys_id);
With
- incident.addQuery("parent_incident", current.sys_id);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2015 04:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2015 04:18 AM
Sorry also meant to ask/check that by using gs.getUser in this context it will return the current (i.e. child incident) customer language/location details as opposed to logged in user?
Thanks!
Daniel