Create "request escalation" Widget for Service Portal

robinsamberg
Tera Expert

Hi all,

I'm looking to do something very much like the "reopen incident button" widget described here (which works perfectly, BTW, thank you), but what I need is to have a button that will allow our users to request escalation of their issue.  We are not using SLA/Workflow to automatically escalate incidents (yet) and we are not quite ready to. 

https://community.servicenow.com/community?id=community_article&sys_id=db298e11db97d380fece0b55ca96195f

I would imagine the solution in the linked article can be modified to do what we need it to, I'm just not sure where to start.  The desired outcome would be:  User clicks a "Request Escalation" button in the service portal, types their reason, and clicks SUBMIT.  The Submit button (ideally) would do 2 things:  Add the escalation request reason to the incident comments, and send the incident info and escalation request notification to a designated group of people.

I am not a coder/scripter but I can follow directions easily, as long as they are clear 🙂

Thoughts?  Thank you!

1 ACCEPTED SOLUTION

Thank you very much Pradeep, I was able to implement this with minor changes very easily.  All I changed was the button visibility - from "only show if state is resolved" to "only show if state is new/in progress/on hold".  

Also added a new state "Escalated", which as suggested is triggering the email notification.  

 

View solution in original post

11 REPLIES 11

Morning Pradeep

I have come across your script which works perfectly for Incidents, but we need to be able to give our users the ability to escalate Requests to.

Can you please give me some assistance with amending the Server Script to also include the sc_request table on the same widget, as I am getting an error on the code

Just for your awareness I have a checkbox on the incident (u_escalate_this_incident) and request  (u_escalate_this_service_request) forms which is ticketed if the ticket is escalated

This is what I have done:-

 

(function() {

// Get table & sys_id
data.table = input.table || $sp.getParameter("table");
data.sys_id = input.sys_id || $sp.getParameter("sys_id");

// Valid GlideRecord
var gr = new GlideRecord(data.table);
if (!gr.isValid())
return;

// Valid sys_id
if (!gr.get(data.sys_id))
return;

//Button Visibility
if(data.table == 'incident' && gr.active == true && (gr.incident_state == 2 || gr.incident_state == 3) && gr.u_escalate_this_incident == false && (gr.caller_id == gs.getUserID() || gr.opened_by == gs.getUserID())){
if(data.table == 'sc-request' && gr.active == true && gr.u_escalate_this_service_request == false && (gr.caller_id == gs.getUserID() || gr.opened_by == gs.getUserID())){
data.showWidget = true;
data.showReopen = true;

} else {
data.showWidget = false;
data.showReopen = false;
}

//input
if (input && input.action === 'reopen') {

// If Incident table
if (data.table == 'incident') {
gr.setValue('u_escalate_this_incident', 'true');
gr.comments = "Ticket Escalate. \nEscalated with comments: "+ input.reopenComments;
gr.update();

if (data.table == 'sc_request'){
gr.setValue('u_escalate_this_service_request',true)
gr.comments = "Ticket Escalate. \nEscalated with comments: "+ input.reopenComments;
gr.update();
}
}
})();

 

 

find_real_file.png

Hi Jonathan,

Try this, it worked for me:

Instead of:

//Button Visibility
if(data.table == 'incident' && gr.active == true && (gr.incident_state == 2 || gr.incident_state == 3) && gr.u_escalate_this_incident == false && (gr.caller_id == gs.getUserID() || gr.opened_by == gs.getUserID())){
if(data.table == 'sc-request' && gr.active == true && gr.u_escalate_this_service_request == false && (gr.caller_id == gs.getUserID() || gr.opened_by == gs.getUserID())){

data.showWidget = true;
data.showReopen = true;

} else {
data.showWidget = false;
data.showReopen = false;
}

 

Try:

//Button Visibility
if(data.table == 'incident' || 'sc_request' && gr.active == true && (gr.incident_state == 2 || gr.incident_state == 3) && gr.u_escalate_this_incident == false && (gr.caller_id == gs.getUserID() || gr.opened_by == gs.getUserID()))

{
data.showWidget = true;
data.showReopen = true;

}
else {
data.showWidget = false;
data.showReopen = false;
}

 

And change:

// If Incident table
if (data.table == 'incident') {
gr.setValue('u_escalate_this_incident', 'true');
gr.comments = "Ticket Escalate. \nEscalated with comments: "+ input.reopenComments;
gr.update();

if (data.table == 'sc_request'){
gr.setValue('u_escalate_this_service_request',true)
gr.comments = "Ticket Escalate. \nEscalated with comments: "+ input.reopenComments;
gr.update();
}
}
})();

To:

// If Incident table
if (data.table == 'incident' || 'sc_request') {
gr.setValue('u_escalate_this_incident', 'true');
gr.comments = "Ticket Escalate. \nEscalated with comments: "+ input.reopenComments;
gr.update();

Also, make sure you have as "sc_request" not "sc-request" (you have the latter in your snippet).

I hope this helps.

And much thanks to Pradeep and @robinsamberg for providing the code to begin with.

Hi @Pradeep Sharma  , can you tell me how to do it for HR Case?

Vikram3
Giga Guru

Hi Robin,

I created an escalate widget for incident which will be enabled when any one of the SLA is breached of that incident. Attached is my snippet.

Modify this as per your needs.

Below are the screenshots.

find_real_file.png

 

Thanks so much for your suggestion and XML file!  I did try to implement this, but until I have time to figure out everything I need to have in place - I had to go with Pradeep's solution for now.  I appreciate your reply!

Robin