- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2019 10:13 PM
I want to add Confirm Pop message "Please make sure problem workaround field has been updated before closing incident"
Button --- CONFIRM or CANCEL
If user select CONFIRM button UI Action will RUN.
If user select CANCEL button UI action will not RUN and stays in same page.
Current UI Action script code is as below on problem table.
var incident = new GlideRecord("incident");
incident.addQuery("problem_id", "=", current.sys_id);
incident.addQuery("incident_state", "=", IncidentState.AWAITING_PROBLEM);
if ( (typeof IncidentReason) !== "undefined" )
incident.addQuery("hold_reason", "=", IncidentReason.AWAITING_PROBLEM);
incident.query();
while (incident.next()) {
incident.incident_state.setValue(IncidentState.RESOLVED);
incident.close_notes = 'This incident is resolved based on workaround provided in related problem investigation number ' + current.number + '.' + ' The Workaround is ' + '(' + current.work_around + ')';
incident.close_code = 'solved_workaround';
incident.update();
gs.addInfoMessage(gs.getMessage('Related Incidents Resolved'));
action.setRedirectURL(current);
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2019 03:31 AM
You are using server side code in the client side.
Try the below script and see if it works
function resolveIncidents() {
var answer = confirm("Please ensure workaround field has been updated before resolving related incidents.");
if (answer == true) {
gsftSubmit(null, g_form.getFormElement(), 'resolveincidents');
} else {
return false;
}
}
if (typeof window == 'undefined')
resolveIncidentFunction();
function resolveIncidentFunction() {
var incident = new GlideRecord("incident");
incident.addQuery("problem_id", "=", current.sys_id);
incident.addQuery("incident_state", "=", IncidentState.AWAITING_PROBLEM);
if ((typeof IncidentReason) !== "undefined")
incident.addQuery("hold_reason", "=", IncidentReason.AWAITING_PROBLEM);
incident.query();
while (incident.next()) {
incident.incident_state.setValue(IncidentState.RESOLVED);
incident.close_notes = 'This incident is resolved based on workaround provided in related problem investigation number ' + current.number + '.' + ' The Workaround is ' + '(' + current.work_around + ')';
incident.close_code = 'solved_workaround';
incident.update();
gs.addInfoMessage(gs.getMessage('Related Incidents Resolved'));
action.setRedirectURL(current);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2019 03:17 AM
I have tried by updating below script as onclick but UI action does not run if I am selecting OK or CANCEL button. Can anyone help by fixing this code.
function resolveIncidents(){
var answer=confirm("Please ensure workaround field has been updated before resolving related incidents.");
if (answer==true){
var incident = new GlideRecord("incident");
incident.addQuery("problem_id", "=", current.sys_id);
incident.addQuery("incident_state", "=", IncidentState.AWAITING_PROBLEM);
if ( (typeof IncidentReason) !== "undefined" )
incident.addQuery("hold_reason", "=", IncidentReason.AWAITING_PROBLEM);
incident.query();
while (incident.next()) {
incident.incident_state.setValue(IncidentState.RESOLVED);
incident.close_notes = 'This incident is resolved based on workaround provided in related problem investigation number ' + current.number + '.' + ' The Workaround is ' + '(' + current.work_around + ')';
incident.close_code = 'solved_workaround';
incident.update();
gs.addInfoMessage(gs.getMessage('Related Incidents Resolved'));
action.setRedirectURL(current);
}
}
else
{
return false;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2019 03:31 AM
You are using server side code in the client side.
Try the below script and see if it works
function resolveIncidents() {
var answer = confirm("Please ensure workaround field has been updated before resolving related incidents.");
if (answer == true) {
gsftSubmit(null, g_form.getFormElement(), 'resolveincidents');
} else {
return false;
}
}
if (typeof window == 'undefined')
resolveIncidentFunction();
function resolveIncidentFunction() {
var incident = new GlideRecord("incident");
incident.addQuery("problem_id", "=", current.sys_id);
incident.addQuery("incident_state", "=", IncidentState.AWAITING_PROBLEM);
if ((typeof IncidentReason) !== "undefined")
incident.addQuery("hold_reason", "=", IncidentReason.AWAITING_PROBLEM);
incident.query();
while (incident.next()) {
incident.incident_state.setValue(IncidentState.RESOLVED);
incident.close_notes = 'This incident is resolved based on workaround provided in related problem investigation number ' + current.number + '.' + ' The Workaround is ' + '(' + current.work_around + ')';
incident.close_code = 'solved_workaround';
incident.update();
gs.addInfoMessage(gs.getMessage('Related Incidents Resolved'));
action.setRedirectURL(current);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2019 04:02 AM
Thank you very much. It is working now perfectly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2025 11:10 PM
Does it work on workspace?