- 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-13-2015 07:23 AM
I've also tried e.g.
&& current.location != "183cb56889ee4d005f2c0203c80f60d6"
&& current.location != "Montreal"

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2015 08:32 PM
If it needs to be based on user location, think this is the method to use
gs.getUser().getLocation()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2015 03:22 AM
Thanks Kalai really appreciate this update/help.
However it's dawned on me that my thinking on this had its flaws. This UI Action obviously exists to resolve child incidents easily. Part of the UI Action, copies text in to the resolution notes if that field is blank. Now the new UI Action was going to exist to ensure that when the Customer is from Montreal or Quebec this text could be the French version. Of course however just because the parent incident customer is from either of those does not mean the child incident customers will be! So the script is currently as below:
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);
*********************************************************************
*******************************************************
could you please possibly advise on how I could make the below part include a line so that if the current customer is from e.g. Montreal or Quebec the text is the French translation instead of the English... don't worry I'm not asking you to translate for me, ha!
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_;
}
Many thanks indeed.
Daniel

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2015 03:51 AM
You can add condition inside the if condition to check if the current user's language and update msg parameter accordingly.
if (current.u_customer_visible_resolution_.nil()) {
if(gs.getUser().get language()=='fr') //verify if French will return fr or not
{
msg='french message';
}
else
{
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2015 04:14 AM
Thanks Kalai, but can I still add:
else
{
incident.u_customer_visible_resolution_ = current.u_customer_visible_resolution_;
}
to the end i.e. it's OK to have two elses? This is needed so the text is not replaced if there is something already there in the field.
I don't think we currently utilise the 'Language' field so will look into this but for now could location be swapped in for language like below and if so is sys ID right?
(gs.getUser().get language()=='fr')
I.e. for location would be (gs.getUser().getLocation()=='sys ID')
Thank-you.