Service Portal Reopen Incident Widget

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2017 08:55 AM
So I have created an Reopen Incident widget based largely on the Resolve Incident widget from ServiceNow Elite (http://www.servicenowelite.com/blog/2017/5/12/service-portal-resolve-incident-button ). It's basically doing the same thing, except it sets incident state back to Active and updates the Additional Comments Journal field. It works great, HOWEVER, it is behaving inconsistently where it will usually make duplicate entries into the Additional Comments sometimes 2, 3, or 4 duplicates and sometimes correctly enters just once with no rhyme or reason. I am curious if anyone else has seem this behavior. Code is below.
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">Reopen Incident</button>
<div ng-if="data.response1" class="alert alert-info">{{::data.response1}}</div>
</div>
</div>
<script>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">Provide a reason for the reopening</h4>
</div>
<div class="panel-body wrapper-xl">
<form name="modalTemplateReopen" ng-submit="c.uiAction('reopen')">
<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>
</script>
Server Script
(function() {
// Get table & sys_id
data.table = input.table || $sp.getParameter("table");
data.sys_id = input.sys_id || $sp.getParameter("sys_id");
// Valid GlideRecord
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 == 6 && gr.caller_id == gs.getUserID()){
data.showWidget = true;
data.showReopen = true;
} else {
data.showWidget = false;
data.showReopen = false;
}
//input
if (input && input.action) {
var action = input.action;
// If Incident table
if (data.table == 'incident') {
if (action == 'reopen') {
gr.setValue('incident_state', 2);
gr.setValue('state', 2);
//gr.setValue('resolved_by', gs.getUserID());
gr.comments = "Reopened by caller with comment: " + input.reopenComments;
gr.update();
//data.response1 = gs.getMessage('Incident '+gr.number+' was resolved');
}
}
}
})();
Client Controller
function($uibModal, $scope, spUtil) {
var c = this;
$scope.$on('record.updated', function(name, data) {
spUtil.update($scope);
})
c.uiAction = function(action) {
c.data.action = action;
c.server.update().then(function() {
c.data.action = undefined;
})
c.modalInstance.close();
}
c.openModalReopen = function() {
c.modalInstance = $uibModal.open({
templateUrl: 'modalTemplateReopen',
scope: $scope
});
}
c.closeModal = function() {
c.modalInstance.close();
}
}
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2018 12:56 AM
How does the HTML work? I keep getting errors around the <script> tags, as they have <div> inside them.
Unfortunately the Servicenowelite page is no longer there
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2020 03:00 AM
Hi,
Please check below article which shows how to create reopen incident button in Service Portal in 3 easy steps:
https://glidecenter.com/add-reopen-button-in-service-portal/
Thanks,
Pritam

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2020 06:00 AM
It looks like same as my article