ServiceNow Incident to Requested Item

Published by Shawn on

Introduction

There have been multiple situations over the years where organizations that are implementing ServiceNow are also implementing for the first time some type of ITIL governance.  The steps below walk you through configuring an UI Action script that gives users with the ITIL role the ability to convert a ServiceNow incidents to a generic ServiceNow requested item.  At the same time updating the incident work notes and ultimately canceling the ServiceNow incident.

Walkthrough

Using the ServiceNow navigator type in “incident.list” and hit enter.  This will take you to a list of Incidents in ServiceNow.

Open any Incident by clicking on the number.  Once you are on the default form for the ServiceNow Incident right click on the form menu bar and select “Configure” then “UI Actions”.

When the UI Action list loads click the “New” button.

Name: Convert (To RITM) . <- This can be anything you wish
Action Name: convert_inc_to_ritm <- The action name is important as it is used as part of the script
Client: Checked
Form Button: Checked
Hint: Clicking this button will cancel the Incident and create a generic requested item
Script:

function confirmMorph() {
  var conf = confirm("If you would like to convert this incident into a generic requested item, click OK. Otherwise click Cancel to return to the form.");
  if (conf){
// runs the UI action convert() from server if confirm is true gsftSubmit(null, g_form.getFormElement(), 'convert_inc_to_ritm'); } else { return false; } } function convert() { // create a cart as the current user var cart = new Cart(null, gs.getUserID());
// place order - submit cart var rc = cart.placeOrder(); // find the ritm create when order was placed var ritm = new GlideRecord('sc_req_item'); ritm.addQuery('request',rc.sys_id); ritm.query(); var incident_id = current.sys_id; var description = current.description; var short_description = current.short_description; while (ritm.next()) {
// update the incident work notes and cancel the incident current.state = 8; current.work_notes = "Incident converted to Generic Request: " + ritm.number; ritm.u_rel_incident = incident_id; ritm.short_description = short_description; ritm.description = description; ritm.update(); current.update();

That is it!  Save the UI action and test it out.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.