Add Confirm Pop up message in UI Action.

Abhishek Dixit1
Kilo Expert

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);
}

 

1 ACCEPTED SOLUTION

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);
    }
}

View solution in original post

8 REPLIES 8

Manas Kandekar
Kilo Guru

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);
}

}

Manas Kandekar
Kilo Guru

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);
}
}

Service_RNow
Mega Sage

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,

Thanks but its not helpful.