- 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-12-2019 10:59 PM
var usrResponse = confirm('Please make sure problem workaround field has been updated before closing incident');
if (usrResponse == 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);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2019 11:00 PM
var usrResponse = confirm('Please make sure problem workaround field has been updated before closing incident');
if (usrResponse == 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);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2019 11:29 PM
try this.. had answered a similar question...
Re: Cancel confirm window after clicking cancel button
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2019 01:00 AM
Thanks but its not helpful.