Blog

Incident Data Load

This article has an example method to import Incidents without History or relationship information from another ITSM application. There are many different ways to import data in ServiceNow and this is one example method. For your imports you will need to adjust accordingly.

Note: It should be discouraged to import old Incidents, especially a large number of Incidents that can add a performance burden on a new system. However it sometimes is necessary to import a selected number of incidents.

Wiki Articles for reference:

http://wiki.servicenow.com/index.php?title=Import_Sets
http://wiki.servicenow.com/index.php?title=Creating_New_Transform_Maps
http://wiki.servicenow.com/index.php?title=Transform_Map_Scripts

Example Incident Import

  1. Turn off Email

    Turn off email on system if activated.

  2. Create Excel File

    Create an excel file with columns such as:

    • Assigned To
    • Assignment Group
    • Caller ID
    • Category
    • Close Time (Format: yyyy-mm-dd)
    • Closed By
    • Close Code
    • Close Notes
    • Configuration Item
    • Contact Type
    • Description
    • Impact
    • Location
    • Opened At (Format: yyyy-mm-dd)
    • Opened By
    • Short Description
    • Status
    • Subcategory
    • Urgency
  3. Load Data

    Load Data into Import Set Table:

    • Label: Incident Data Upload

    After Import Set Table is created, Click Create Transform Map link.

  4. Transform Map

    Setup Transform Map:

    • Name: Incident Data Upload
    • Source Table: Incident Data Upload
    • Target Table: Incident
    • Run Business Rules: true
    • Enforce Mandatory fields: No
    • Copy empty fields: false

    Transform Map (Field Map)

    Source field | Target field | Coalesce | Choice Action | Date Format
    u_assigned_to | assigned_to | FALSE | ignore
    u_assignment_group | assignment_group | FALSE | ignore
    u_caller_id | caller_id | FALSE | ignore
    u_category | category | FALSE | ignore
    u_close_time | closed_at | FALSE | ignore | yyyy-MM-dd hh:mm:ss
    u_closed_by | closed_by | FALSE | ignore
    u_close_code | close_code | FALSE | ignore
    u_close_notes | close_notes | FALSE | ignore
    u_configuration_item | cmdb_ci | FALSE | ignore
    u_contact_type | contact_type | FALSE | ignore
    u_description | description | FALSE | ignore
    u_impact | impact | FALSE | ignore
    u_location | location | FALSE | ignore
    u_opened_at | opened_at | FALSE | ignore | yyyy-MM-dd hh:mm:ss
    u_opened_by | opened_by | FALSE | ignore
    u_short_description | short_description | FALSE | ignore
    u_status | state | FALSE | ignore
    u_subcategory | subcategory | FALSE | ignore
    u_urgency | urgency | FALSE | ignore

  5. Transform Script

    Reference fields are stored as sys ids in a ServiceNow table, so we need transform scripts to convert the data we imported for reference fields to sys ids. Below are some example conversions for reference fields:

    • When: onBefore
    • Order: 100
    • Script:
    //Set Opened At Time
    var dtOpenedAt = source.u_opened_at.getGlideObject();
    dtOpenedAt.addSeconds(-7200);
    target.opened_at = dtObj;
    //Find Assigned To
    var grAssignedTo = new GlideRecord('sys_user');
    grAssignedTo.addQuery('name','STARTSWITH',source.u_assigned_to);
    grAssignedTo.query();
    if (grAssignedTo.next()) {
     target.assigned_to = grAssignedTo.sys_id;
    }
    //Find Caller
    var grCaller = new GlideRecord('sys_user');
    grCaller.addQuery('name','STARTSWITH', source.u_caller_id);
    grCaller.query();
    if (grCaller.next()) {
     target.caller_id = grUser.sys_id;
    }
    //Find Closed By
    var grClosedBy = new GlideRecord('sys_user');
    grClosedBy.addQuery('name','STARTSWITH',source.u_closed_by);
    grClosedBy.query();
    if (grClosedBy.next()) {
     target.closed_by = grClosedBy.sys_id;
    }
    //Find Opened By
    var grOpenedBy = new GlideRecord('sys_user');
    grOpenedBy.addQuery('name','STARTSWITH',source.u_opened_by);
    grOpenedBy.query();
    if (grOpenedBy.next()) {
     target.opened_by = grOpenedBy.sys_id;
    }
  6. Transform!

    After your Import Set, Transform Map, and Transform Script are ready. Transform the Import Set you created.

  7. Purge Emails and Turn on Email

    Purge any emails in the Email Log that you don't want sent and Turn on Email