- 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-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-09-2015 05:53 AM
Not entirely sure what I'd do without you and Victor at the moment! Big thanks Kalai. As a result of this answer, can I please ask:
If the line incident.addQuery("current.parent_incident", "=", current.sys_id);
was wrong, does this also mean the below are too?
incident.addQuery("incident_state", "!=", "6");
incident.addQuery("incident_state", "!=", "7");

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2015 05:58 AM
Nope.. Those are alright.. You just needed to remove current. from the query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2015 07:22 AM
Hi Kalai! Can you hide UI Actions based on Customer location (location is on the INC form and is auto populated)? In regard to this UI Action I need to hide it from users in 2 locations, the current UI Action condition is:
current.child_incidents != 0 && current.incident_state == 6 || current.incident_state == 7 && gs.hasRole("itil")
This works fine. However I am trying to add an extra condition so that when e.g. Montreal is the customer location it will not show the UI Action. I have tried adding the below to the end of the above condition but to no avail:
&& (gs.getUser().getLocation() != '183cb56889ee4d005f2c0203c80f60d6')
I also tried changing syntax to:
&& gs.getUser().getLocation() != ('183cb56889ee4d005f2c0203c80f60d6')
Although now I realise this is for logged in user not the customer! Looong day!
Thanks for any input on this.
Daniel