Add ability to reopen incident ticket on Service Portal

JC S_
Mega Guru

Hello, we are currently looking to implement ability for end-user to reopen an incident through the Service Portal. Currently the only way our end-users can do this is by clicking a button on an email notification which sends an email to ServiceNow which is then processed by an inbound action to reopen an incident.

Perhaps we can add a button on the ticket form that will only show if the state of current incident ticket is Resolved.

1 ACCEPTED SOLUTION

Hi ddiroma, I also found those resources and was able to implement a custom widget that will add the buttons needed. This is the best way to approach this especially since we are using the Ticket page which is quite different than the default Self-Service view of incident form (which is where the built-in Reopen button will show as per solution provided by sb1186.



To summarize the approaches we found out to resolve this:



Option 1


If you are using the default incident form (Self-Service view on Service portal) then use the UI Action built-in on ServiceNow:


1) Go to System UI > UI Actions


2) Search for the Reopen Incident UI Action on Incident table.


3) Adjust Condition to suit your requirements.


4) This will add Reopen Incident button on the incident form.



Option 2


If you are using a custom page to show incident details:
1) Create a custom widget with action button that will update the necessary fields (change state to Resolved, add comments, etc.)


2) Add the custom widget on the page.


3) Check out these external resources 1 and 2 to help you on developing your custom action buttons.


View solution in original post

16 REPLIES 16

Karthik,


Here is my code. Keep in mind that coding is not my strong suit, but I tend to get by. I borrowed some of the code from others. Also keep in mind that we have a number of custom fields such as impacted user and a number of the fields that get updated upon reopen. The field "controllerAs" is set c in the widget. I also have messages for a number of things like Reopen Incident as our instance is in 6 languages. I hope this helps.



Body HTML Template


<div ng-if="data.showWidget">


<div class="panel panel-default">


  <div class="panel-heading">Actions</div>


  <div class="panel-body">


      <textarea ng-model="c.data.reason" placeholder="${Reopen Reason}" class="form-control"/>


<button type="button" class="btn btn-primary btn-block" ng-click="c.uiAction('reopen')" ng-if="data.showReopen">${Reopen Incident}</button>


  </div>


</div>


</div>


CSS is blank


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.incident_state == 5 && gr.caller_id == gs.getUserID()) || (data.table == 'incident' && gr.incident_state == 5 && gr.u_impacted_user == gs.getUserID())){


data.showWidget = true;


data.showReopen = true;


}


else {


data.showWidget = false;


data.showReopen = false;


}



// Check state value


      data.state = gr.getValue('state');


data.incident_state = gr.getValue('incident_state');


data.approval = gr.getValue('approval');



if (input && input.action) {


var action = input.action;//Get action value




// Get other required values


var onBehalfOf = gr.getValue('u_impacted_user');


var caller = gr.getValue('caller_id');


var currentUser = gs.getUserID();


var comments = input.reason;


var msg1 = gs.getMessage('Adding information in Reopen Reason is mandatory.');


var msg2 = gs.getMessage('Only Caller or Impacted User can reopen incident');




// Check if table is incident and action is reopen


if(data.table == 'incident'){


if (action == 'reopen') {



// Check if current user is caller or impacted user and reopen comments are not blank


if(onBehalfOf == currentUser || caller == currentUser){


if(comments == "" || comments == undefined){


gs.addErrorMessage(msg1);


return false;


}


else{


// Update values comments and state


gr.comments = comments;


gr.state = 1;


gr.incident_state = 2;


gr.close_code = "";


gr.close_notes = "";


gr.u_issue_type = "";


gr.u_issue_category = "";


gr.u_external_tickt_reference = "";


gr.u_resolution_detail = "";


data.reason = "";// Update reopen reason field with empty value


gr.update();


}


}else{


gs.addErrorMessage(msg2);


}


}


}


}



})();


Client Controller


function($scope) {


  var c = this;


c.uiAction = function(action) {


c.data.action = action;


c.server.update().then(function() {


c.data.action = undefined;


})


}


}


Community Alums
Not applicable

Thanks Dion, i have checked almost all the available widgets for incident actions


Thank you greatly for posting this. As you've mentioned, you have some custom fields so it does require a slight bit of editing, but this is wonderful.



Now I just need to research how to hide the 'Type your message here...' message bar and send button on the Ticket Conversations widget when the incident is in Resolved or Closed status and we'll be set!.



That ensures (for me anyway) that they can only:



1) Reopen an incident while in Resolved state


2) NOT reopen an incident once it's closed (which it hits closed status after 5 days)


3) NOT see the message bar and send button in the ticket form page while in closed or resolved status


4) Prevents our analysts from getting a ticket back that just says: Thanks! or something similar


5) Prevents our analysts from getting an incident reopened that was closed


6) This also erases out the close code comments and status and makes the analyst have to redo it again...which they should since the incident was reopened.



Thanks!



Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

ddiroma
Mega Expert

Hi sb1186,


It wouldn't let me reply to your comment directly so I am mentioning you in this comment. Note that value of 5 in our incident_state is Resolved.


find_real_file.png


Thank you,


Dion


Pritam Mangrulk
Mega Contributor

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