ReOpen Incident Option on Service portal for end users.

Ishita Shrivast
Kilo Guru

Hello Everyone,

I have a requirement where I need to provide Reopen option for incidents to end users on portal. We have this "Incident Standard Ticket Actions" OOB widget which already has the option of Reopen but it is not available on portal, only options Resolve and Close are visible. I don't have much experience in Service Portal so I am wondering how can I enable this Reopen option without creating another widget. For references , please see attachments.

Thanks in Advance,

Ishita.

 

 

12 REPLIES 12

@Ankur Bawiskar 

Hi Ankur,

This link did not provided me the exact solution that I was looking for but I did got some help from this link. I was able to create the functionality and it is working fine now our PROD instance. Thanks for your reply.

Regards,
Ishita.

@Ishita Shrivastava 

Glad to know the link I shared helped you.

Thank you for marking my response as helpful.

If my response helped you please mark it correct to close the question so that it benefits future readers as well.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ishita Shrivastava 

It would be nice if you share your complete approach so that it helps members in future.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Ishita Shrivast
Kilo Guru

So, here's what I did.

I cloned the widget "Incident Standard Ticket Actions".

I also created a copy of Script Includes that was being used in Service Side Script, namely, IncidentUtils2SNC & IncidentUtils2 because I needed to update the condition which will allow users to have Reopen option and IncidentUtils2SNC is OOB Script which we cannot edit. Below is code snippet for my widget.

After making all the changes , I navigated to "Standard Ticket Configuration"-> incident -> For Action Widget field , I selected the Cloned Widget that I created and saved the record.

 

HTML- 

<div>
<div class="dropdown" id="child-case-tabs" ng-if="data.showActions">
<button type="button" class="btn btn-default dropdown-toggle action-btn" data-toggle="dropdown" style="width : 100%">
${Actions}
<span class="caret"></span>
</button>
<ul class="dropdown-menu" id="actionList">
<li>
<a ng-if="data.canResolve" href="javascript:void(0)" ng-click="$event.stopPropagation();resolveIncident()">Resolve</a>
</li>
<li>
<a ng-if="data.canReopen" href="javascript:void(0)" ng-click="$event.stopPropagation();reopenIncident()">Reopen</a>
</li>
<li>
<a ng-if="data.canClose" href="javascript:void(0)" ng-click="$event.stopPropagation();closeIncident()">Close</a>
</li>
</ul>
</div>


</div>

 

Service Side Script- 

(function() {
var incidentGr = new GlideRecord('incident');
var incidentSysId = options.sys_id;

if (!incidentSysId && $sp.getParameter('table') == 'incident')
incidentSysId = $sp.getParameter('sys_id');

if (!incidentSysId && $sp.getParameter('table') == 'universal_request') {
var urGr = new GlideRecord('universal_request');
urGr.get($sp.getParameter('sys_id'));
incidentSysId = urGr.primary_task + "";
}

/* Actions - Start */
if (input && input.action == 'resolveIncident' && incidentGr.get(incidentSysId)) {
incidentGr.incident_state = global.IncidentState.RESOLVED;
incidentGr.state = global.IncidentState.RESOLVED;
incidentGr.resolved_by = gs.getUserID();
incidentGr.update();
}

if (input && input.action == 'reopen' && incidentGr.get(incidentSysId)) {

incidentGr.incident_state = global.IncidentState.IN_PROGRESS;
incidentGr.state = global.IncidentState.IN_PROGRESS;
incidentGr.assigned_to='';

incidentGr.comments = "Ticket reopened. \nReopened with comments: "+ input.reopenComments;
incidentGr.update();
// gs.addInfoMessage(gs.getMessage("Request reopened"));

}


if (input && input.action == 'closeIncident' && incidentGr.get(incidentSysId)) {
incidentGr.incident_state = global.IncidentState.CLOSED;
incidentGr.state = global.IncidentState.CLOSED;
incidentGr.update();
}

/* Actions - End */

/* Load incident data */
if (incidentGr.get(incidentSysId)) {
var incidentUtil = new global.IncidentUtil();
data.canResolve = incidentUtil.canResolveIncident(incidentGr);
data.canReopen = incidentUtil.canReopenIncident(incidentGr);
data.canClose = incidentUtil.canCloseIncident(incidentGr);
data.showActions = data.canResolve || data.canReopen || data.canClose;
}

data.i18n = {};

})();

 

Client Side Script-

function incidentTicketActions($scope, $http, spUtil, $timeout, spModal, i18n, $window, $uibModal) {
/* widget controller */
var c = this;
c.doneLoading = false;

var MOBILE_DEVICE_SCREEN_WIDTH = 767;
$scope.mobileDevice = c.data.isMobile || ($window.innerWidth < MOBILE_DEVICE_SCREEN_WIDTH);


$scope.resolveIncident = function() {
$scope.data.action = 'resolveIncident';
$scope.server.update(init);
};

$scope.closeIncident = function() {
$scope.data.action = 'closeIncident';
$scope.server.update(init);
};

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

c.Reopen = function(action) {
c.data.action = action;
c.server.update().then(function() {
$scope.data.action = undefined;
spUtil.addInfoMessage("Incident has been Reopened", 3000);

});

}

$scope.reopenIncident = function() {
c.data.action = 'reopenIncident';
c.modalInstance = $uibModal.open({
templateUrl: 'modalTemplateReopen',
scope: $scope
})
c.server.update(init);

}

c.closeModal = function() {
c.modalInstance.close();
};

function init() {}

$(document).on('click', 'div.modal-footer button.btn, ul#child-case-tabs .dropdown-menu', function(e) {
e.stopPropagation();
});

$(document).bind('dragover drop', function(event) {
event.preventDefault();
return false;
});

$scope.$on('sp_loading_indicator', function(e, value) {
if (!value && !c.doneLoading) {
c.doneLoading = true;
}
});

}

 

On Script Include IncidentUtils2SNC (Copied version, not the OOB), I made a small change for my condition on below function-

canReopenIncident: function(current) {
return current.incident_state == IncidentState.RESOLVED && gs.getUser().hasRoles() && !this._isMajorIncident(current);
},

 

Hope this will help someone in future.

Regards,

Ishita.

diannemcintosh
Tera Contributor

Can you make comments mandatory when reopen is selected?