if (input && input.action == 'escalateIncident' && incidentGr.get(incidentSysId) && hasPermissions(incidentGr, "write")) {
var assignedToName = '';
var assignmentGroupManagerName = '';
if (incidentGr.assigned_to) {
var assignedToGr = new GlideRecord('sys_user');
if (assignedToGr.get(incidentGr.assigned_to)) {
assignedToName = assignedToGr.name.getDisplayValue();
}
}
// Get the manager of the assignment group
if (incidentGr.assignment_group) {
var assignmentGroupGr = new GlideRecord('sys_user_group');
if (assignmentGroupGr.get(incidentGr.assignment_group)) {
var managerGr = new GlideRecord('sys_user');
if (managerGr.get(assignmentGroupGr.manager)) {
assignmentGroupManagerName = managerGr.name.getDisplayValue();
}
}
}
var workNotes;
// Check if both the assigned-to person and the manager are empty
if (!assignedToName && !assignmentGroupManagerName) {
workNotes = 'To whom it may concern,\n\n' +
'Please note that the customer has escalated this incident. The ticket has been reassigned to the DISC for further handling. The DISC will reach out to the team lead to clarify the situation and agree on a resolution plan.\n\n' +
'Best regards,\nJarvis';
}
// Check if only the assigned-to person is empty and the manager is present
else if (!assignedToName && assignmentGroupManagerName) {
workNotes = 'Dear ' + assignmentGroupManagerName + ',\n\n' +
'Please note that the customer has escalated this incident. The ticket has been reassigned to the DISC for further handling. The DISC will reach out to the team lead to clarify the situation and agree on a resolution plan.\n\n' +
'Best regards,\nJarvis';
}
// Check if the assigned-to person is present and the manager is empty
else if (assignedToName && !assignmentGroupManagerName) {
workNotes = 'Dear ' + assignedToName + ',\n\n' +
'Please note that the customer has escalated this incident. The ticket has been reassigned to the DISC for further handling. The DISC will reach out to the team lead to clarify the situation and agree on a resolution plan.\n\n' +
'Best regards,\nJarvis';
}
// If both assigned-to person and manager are present
else {
workNotes = 'Dear ' + assignedToName + ', Dear ' + assignmentGroupManagerName + ',\n\n' +
'Please note that the customer has escalated this incident. The ticket has been reassigned to the DISC for further handling. The DISC will reach out to the team lead to clarify the situation and agree on a resolution plan.\n\n' +
'Best regards,\nJarvis';
}
incidentGr.assigned_to = '';
incidentGr.assignment_group = gs.getProperty('xxld_escalated_incident_assignment_group');
incidentGr.work_notes = workNotes;
incidentGr.comments = 'Ticket has been escalated and reassigned to the DISC team.';
incidentGr.u_escalated_status = true;
data.isIncidentEscalated = incidentGr.update();
gs.addInfoMessage(gs.getMessage("Request Escalated"));
} //code ends
/* Actions - End */
/* Load incident data */
if (incidentGr.get(incidentSysId) && hasPermissions(incidentGr, "read")) {
var incidentUtils = new global.IncidentUtils();
// data.canResolve = incidentUtils.canResolveIncident(incidentGr);
data.canReopen = incidentUtils.canReopenIncident(incidentGr);
data.canClose = incidentUtils.canCloseIncident(incidentGr);
data.canEscalate = incidentUtils.canEscalateIncident(incidentGr);
// data.showActions = data.canResolve || data.canReopen || data.canClose;
data.showActions = data.canReopen || data.canClose || data.canEscalate;
}
function hasPermissions(gr, operation) {
if (operation == "read" && gr.canRead())
return true;
if (operation == "write" && gr.canWrite())
return true;
return (gr.getValue("caller_id") == gs.getUserID()) || (gr.getValue("opened_by") == gs.getUserID());
}
data.i18n = {};
})();
Thanks