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

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Robin,

 

Here is the modifed code.

 

HTML:

<div class="panel b" ng-if="data.showWidget">
<div class="panel-heading bg-primary">Actions</div>
<div class="panel-body">
<button type="button" class="btn btn-success btn-block" ng-click="c.openModalReopen()" ng-if="data.showReopen">Request Escalation</button>
<div ng-if="data.response1" class="alert alert-info">{{::data.response1}}</div>
</div>
</div>

Server Side Code:

(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.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 === 'request_escalation') {

// If Incident table
if (data.table == 'incident') {
gr.comments = "Request Escalation: "+ input.reopenComments;
gr.update();
}
}
})();

 

Client Controller:

function ($uibModal, $scope, spUtil) {
var c = this;

$scope.$on('record.updated', function(name, data) {
if(c.data.action == 'request_escalation'){
c.data.action = undefined;
}
spUtil.update($scope);
});

c.Reopen = function(action) {
c.data.action = action;
c.server.update().then(function() {
c.data.action = undefined;
spUtil.addInfoMessage("Incident Is Escalated", 3000);
c.modalInstance.close();
});
};
c.openModalReopen = function() {
c.modalInstance = $uibModal.open({
templateUrl: 'modalTemplateReopen',
scope: $scope
});
};
c.closeModal = function() {
c.modalInstance.close();
};
}

 

Template:

<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">Provide a Request Reason</h4>
</div>
<div class="panel-body wrapper-xl">
<form name="modalTemplateReopen" ng-submit="c.Reopen('request_escalation')">
<div class="form-group">
<textarea required sp-autosize="true" ng-required="true" ng-model="data.reopenComments" id="reopenComments" placeholder="Comments required" class="form-control ng-pristine ng-valid ng-scope ng-empty ng-touched" aria-invalid="false" style="overflow: hidden; word-wrap: break-word; resize: horizontal;"></textarea>
</div>
<input class="btn btn-primary" type="submit" />
</form>
</div>
</div>

 

Is there any state value that should be set when the incident is escalated? If yes, then you can configure the notification according to the filter condition or send dynamically via events.

Note: Untested code.

-Pradeep Sharma

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.  

 

You are very welcome @Robinsamberg. Thanks for participating in the community.

 

-Pradeep Sharma

Robin, would you mind sharing your code? I am unable to get the confirmation (spUtil.addInfoMessage("Incident Is Escalated", 3000);) to show and it never adds the information to the ticket, so clearly I'm doing something wrong or left something out. Similarly to you, I created a new state to accommodate the escalation.

Thanks in advance!