Wednesday, August 17, 2016

ServiceNow Function to Convert Incident to Service Request


function createRequest(incident) {
   var sc_req = new GlideRecord ("sc_request");
   sc_req.initialize();
   sc_req.u_requested_by = current.u_contact_person;
   sc_req.u_requested_by_phone = current.u_contact_phone;
   sc_req.location = current.location;
   sc_req.requested_for = current.caller_id;
   sc_req.phone = current.u_customer_phone;
   sc_req.u_computer_name = current.u_computer_name;
   sc_req.short_description = current.short_description;
   sc_req.description = current.description;
   sc_req.contact_type = current.contact_type;
   sc_req.assignment_group = current.assignment_group;
   sc_req.u_business_service = current.u_business_service;
   sc_req.category = current.category;
   sc_req.subcategory = current.subcategory;
   sc_req.cmdb_ci = current.cmdb_ci;
   sc_req.assigned_to = current.assigned_to;
   sc_req.parent = current.sys_id;
   sc_req.close_notes = current.close_notes;
   sc_req.u_phi_details= current.u_phi_details.getJournalEntry(-1);// -1 gets all journal entries as a string
   sc_req.work_notes = current.work_notes.getJournalEntry(-1);
   var reqSysID = sc_req.insert();

   GlideSysAttachment.copy('incident', current.sys_id, 'sc_request', reqSysID);
   gs.eventQueue("incident.to.request", sc_req, sc_req.number, incident.number);

   gs.addInfoMessage('Request Created: ' + sc_req.number);
   action.setRedirectURL(sc_req);
   
   if (incident.assigned_to.nil()) {
      incident.assigned_to = gs.getUserID();
   }
   incident.state = 7;
   incident.active = false;
   incident.category = 'Request';
   incident.close_code = 'Moved to Request';
   incident.close_notes = 'Moved to Request: ' + sc_req.number;
   incident.comments = 'Moved to Request: ' + sc_req.number;
   incident.parent = reqSysID;
   incident.update();
   gs.addInfoMessage('Incident Closed: ' + incident.number);
}

Tuesday, December 15, 2015

Splunk Integration steps with ServiceNow - Fuji and Eureka Versions


Why do we need to integrate ServiceNow with Splunk?

If you want to enable users to create incidents and events in ServiceNow using the custom generating search commands, custom streaming search commands, or alert-triggered scripts, you must integrate ServiceNow with your Splunk platform instances.


Note: performing push integration with events, ensure that you have the Event Management plugin installed and enabled before you proceed

The below document from the splunk will give step by step instructions for integrating Splunk with ServiceNow

The link to the document is here

Tuesday, November 3, 2015

How to debug the Business Rules or UI Action scripts in ServiceNow

Step1:
Where ever required put the gs.print() or gs.log() statements in the scripts

Step2 - From the SNOW wiki

System Diagnostics > Debug Log displays gs.print() and gs.log() statements as well as server logging information and error messages at the bottom of the content frame. This helps you avoid alternating between the record you are trying to debug and the log output.

Monday, October 6, 2014

Dot walking in ServiceNow Reports

Sometimes we need to access more details about the related fields in the ServiceNow reports.

Scenario

One of the scenario is getting more details about the caller when pulling the reports related to incidents, in that case click the "Show related Fields" in the filtered option to get more details. Do that as shown in the below image.



Saturday, May 17, 2014

Make Work Notes as Mandatory when Assignment Group is Changed on Incident Form


function onChange(control, oldValue, newValue, isLoading, isTemplate) {
 if (isLoading || newValue == '' || oldValue == '') {
  return;
 }
 g_form.flash("incident.work_notes", "#FFFCCC", -4);
 g_form.setMandatory("work_notes", true);
 g_form.addInfoMessage("Please enter work notes when changing assignment groups.");
}

Thursday, March 14, 2013

Change the ServiceNow incident auto close duration from resolved state

We can change the property in the ServiceNow UI properties to automatically close the incidents after a certain period from resolved state.

It can be done as below