Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Anchor
Top of page
Top of page

ServiceNow table

ServiceNow tables

maps are used to map and/or transform outbound ServiceNow field data for the record being dynamic shared or bulk shared. If the field names of the record being shared out from ServiceNow need to be modified, or if the value of one or more fields needs to be transformed, you can create an outbound table map to modify the fields for your integration.


Panel
titleWhat's on this page?

Table of Contents
maxLevel1
absoluteUrltrue


Go to Perspectium > Control and Configuration > Table Maps to access.

Table maps are typically used in Perspectium Service Gateway integrations. For more information about how to use a ServiceNow table map to transform data being shared out of your ServiceNow instance, see Service Gateway.

Outbound Table Maps




Outbound table maps

Outbound Outbound table maps are used to map and/or transform the outbound ServiceNow field data for the replicated records. You should use Outbound table maps if the field names of the replicated record from ServiceNow need to be modified, or if the value of one or more fields needs to be transformed. Once the Outbound table map is configured, it can be assigned to a dynamic share or bulk share share by selecting it in the Table Map field on corresponding forms. See Add a table map to your ServiceNow dynamic share/bulk share.

Outbound table maps are utilized and packaged per integration. See ServiceBond for all the different Perspectium supported applications that uses Outbound table maps.  


↑ Go to top of page




Inbound table maps

Inbound Table Maps

Inbound table maps direct messages to an Import Set Table where a ServiceNow Transform Map will an import set table where a ServiceNow transform map will do the processing. These configurations are used to map inbound replication messages to a ServiceNow table based on the Topic and Type specified in the message. For example, a record coming in with the “topictopic=siam” and siam and the “typetype=common_incident” will incident will be mapped to the “uu_psp_common_incident” Import Set Table. The corresponding Transform Map will incident import set table. The corresponding transform map will then process the message appropriately.


↑ Go to top of page




Create a ServiceNow table map

  1. In your ServiceNow instance, go to Perspectium > Control and Configuration > Table Maps.

  2. Click New.

Explore these features:

  1.  

  2. Select the table map direction (Outbound or Inbound) from the Direction dropdown. The fields available will change depending on whether you choose Outbound or Inbound.

  3. Complete the required fields:
    • Enter a Name
    • (For Outbound table maps only) Select the table you want to create  table map for from the Source table dropdown
    • (For Outbound table maps only) Enter the name of the target table in the Target Table Name field (e.g. incident)
    • (For Inbound table maps only) Select the target table from the Target Table dropdown

  4. Click Submit.


↑ Go to top of page

UI Expandtitle




Add a table map to your ServiceNow dynamic share

/

or bulk share

Divboxstylebackground: white

ServiceNow table maps are typically used in Perspectium Service Gateway integrations to handle the mapping of fields in certain ServiceNow tables as data is shared out of your instance. You can include a table map as part of your ServiceNow dynamic share or bulk share to help with field mappings and data transformation.

Info
titleNotes:
(info) NOTE: 
  • When using a table map with a dynamic share, the dynamic share will trigger based on trigger conditions (i.e. create, update or filter conditions). So this may result in a dynamic share being triggered when a particular field is updated that is not in the table map. As a result, the table mapped record shared out may not have any updated content since all the fields mapped have not changed. To avoid this scenario, use the Share or ignore on specified field updates option.
(info) NOTE: 
  • If a table map is set, records with an attachment or message size greater than 5 MB will not be shared out due to ServiceNow platform limitations with how large one particular record can be.

Prerequisites:

First, you will need to commit create You will also need to 

Instructions:

  1. In your sharing ServiceNow instance, go to Perspectium
 
  1.  > Perspectium Core Shares
 
  1.  > Dynamic Share
 or 
  1.  or Perspectium
 
  1.  > Perspectium Core Shares
 
  1.  > Bulk Share.

  2. Click View Dynamic Shares or View Bulk Shares.

  3. From the available shares, click on the one that you want to add a table map for.

  4. In the Data Enrichment tab, click the search icon next to Table map.

Image Removed


  1. From the resulting list, select the table map you want to add

  2. Click Update (top right
corner
  1. )
to save your changes UI Expand
titleCustomize your target database schema using table maps
Divbox
stylebackground: white
By default, data replicated from existing tables will automatically create the same schema at the replicated database
  1. .
The targeted database schema of replication needs to be flexible and customized in certain situations, such as: 
  • An existing schema that the replicated data need to fit in
  • A need to rename the field names or transform the field values using script at the source
  • The resulting field types need to be modified to a specific type or field length

Customizing target database schema is done by using table maps in your dynamic share or bulk share

Prerequisites:

Instructions:

In your sharing ServiceNow instance, go to Perspectium > Control and Configuration Table Maps
Select the table map you want to use, review the information in the fields, and check the Generate schema box
(warning) WARNINGIf there are multiple table maps with the same Target table name, the agent will return the first record when querying against ServiceNow for the schema.
For the purposes of these instructions, we'll use the table Incident to Common Incident.
NOTES:
 
  • Checking the Generate schema box is required in the initial sharing of your records.
  • Specifying Field Type and Field Length is optional except for designating at least one field as Sys ID (GUID). This is required for the target database table to be created and queried for updates and deletes. 
  • The value specified in the Target table name field will be used as the name of the table in the database.
    Image Removed
    To share the table map output, you need to crate a dynamic share or bulk share and select the table map from step #1 in the table map field. The generated payload can be subscribed by an agent and the scheme created dynamically.
    In this example, the common incident table map will result in the following table schema, if consumed by a database agent for MySQL.
    1.  


    ↑ Go to top of page




    Next, explore some optional configurations for ServiceNow table maps. 

    Code Block
    languagesql
    themeEclipse
    mysql> describe common_incident;
    +---------------------+--------------+------+-----+---------+-------+
    | Field               | Type         | Null | Key | Default | Extra |
    +---------------------+--------------+------+-----+---------+-------+
    | state               | mediumtext   | YES  |     | NULL    |       |
    | short_description   | varchar(160) | YES  |     | NULL    |       |
    | description         | mediumtext   | YES  |     | NULL    |       |
    | priority            | mediumtext   | YES  |     | NULL    |       |
    | attachments         | mediumtext   | YES  |     | NULL    |       |
    | category            | mediumtext   | YES  |     | NULL    |       |
    | correlation_id      | varchar(100) | YES  |     | NULL    |       |
    | number              | varchar(40)  | YES  |     | NULL    |       |
    | correlation_display | varchar(100) | YES  |     | NULL    |       |
    | caller_id           | mediumtext   | YES  |     | NULL    |       |
    | caller_email        | varchar(100) | YES  |     | NULL    |       |
    | caller_full_name    | mediumtext   | YES  |     | NULL    |       |
    | comments            | mediumtext   | YES  |     | NULL    |       |
    | sys_id              | varchar(224) | NO   | PRI |         |       |
    | work_notes          | mediumtext   | YES  |     | NULL    |       |
    +---------------------+--------------+------+-----+---------+-------+
    15 rows in set (0.00 sec)

    (info) NOTE: Even though we specified the number field as the required Sys ID (GUID) field in the table map, the number field does not become the GUID. Instead, the sys_id field is created as GUID (PRI key) and contains number values to be used for lookup during updates/deletes. This is consistent with replicating database views.

    UI Expand
    titleCreate a ServiceNow table map
    Divbox
    stylebackground: white

    Here's how:

    In your ServiceNow instance, go to Perspectium > Control and Configuration > Table Maps
    Click New
    Select the table map direction (Outbound or Inbound) from the Direction dropdown. The fields available will change depending on whether you choose Outbound or Inbound.
    Refer to ServiceNow table maps for more information on the difference between Outbound and Inbound table maps. 
    Complete the required fields:
  • Enter a Name
  • (For Outbound table maps only) Select the table you want to create  table map for from the Source table dropdown
  • (For Outbound table maps only) Enter the name of the target table in the Target Table Name field (e.g. incident)
  • (For Inbound table maps only) Select the target table from the Target Table dropdown
  • Click Submit.
  • UI Expand
    titleCopy a ServiceNow table map
    Divbox
    stylebackground: white

    Existing table maps, as well as transform maps and all other related mappings, can be duplicated or copied. If you plan to modify any of the Common Table Maps, e.g. Incident to Common Incident, we recommend that you modify a new copied table map. 

    Here's how:

    In your ServiceNow instance, go to Perspectium > Control and Configuration > Table Maps
    Select the table map that you want to copy
    Under the Related Links section at the bottom, click Copy table map
    Image Removed
    UI Expand
    titleUse scripts to serialize records
    Divbox
    stylebackground: white

    Table maps can be configured to use scripts to serialize the record yourself. Within the script, you can set the variable answer to be the value you want the record to be serialized and returned as. 

    This is an advance configuration. Contact Perspectium Support for more information. 

    The following variables are available to use:

    VariableDescriptioncurrentThis represents the record that is being sharedgr_tablemapThis represents the outbound table map itself. For example if you want to access the table map's name, you can use gr_tablemap.u_name

    Instructions:

    In your ServiceNow instance, go to Perspectium > Control and Configuration > Table Maps
    Select the table map that you want to add a script to or create a new table map
    Under the Mapping Script section, check the Use Script box
    Fill the Script field with the appropriate script. See below for an example script.
    Click Update.
    UI Expand
    titleClick for example of a table map script
    Divbox
    stylebackground: white
    Code Block
    languagejs
    /*
     * Custom Table Map
     */
     
    //Serialize 'current' record into an XMLDocument
    var recordSerializer = (typeof GlideRecordXMLSerializer != 'undefined') ? new GlideRecordXMLSerializer() : new Packages.com.glide.script.GlideRecordXMLSerializer(); 
    var xmlstr = recordSerializer.serialize(current);
    var xmlDoc = new XMLDocument(xmlstr);
     
    //Process Display Values As Necessary
    var pspUtil = new PerspectiumUtil();
    var addDisplayValues = pspUtil.getPspPropertyValue("com.perspectium.replicator.add_display_values", "true");
    var currentFieldsOnly = pspUtil.getPspPropertyValue("com.perspectium.replicator.share_current_fields", "false");
    if (currentFieldsOnly == "true" || addDisplayValues == "true") {
        addDVFields();
    }
     
    /*
     * Any extra mapping, to add
     */
     
    // Send the XMLDoc string to our answer
    answer = xmlDoc.toString();
     
    // Helper Functions
     
    //Standard DV Field Processing
    function addDVFields(){
        var fl = (typeof GlideFieldList != 'undefined') ? new GlideFieldList() : new Packages.com.glide.processors.FieldList();
        var tableName = current.getTableName();
        var fieldNames = fl.get(current.getTableName(),"");
        var arrFields = current.getFields();
     
        for (var i = 0; i < arrFields.size(); i++) {
            var glideElement = arrFields.get(i);
            var ed = glideElement.getED();
            var elName = glideElement.getName();
     
            if (!fieldNames.contains(elName) || (currentFieldsOnly == "true" && tableName != ed.getTableName())) {
                removeElement(elName);
            }
     
            // Create dv fields for reference, choice, or lists
            if (ed.isReference() || ed.isChoiceTable() || ed.getInternalType() == "glide_list") {
                addElement("dv_" + elName, glideElement.getDisplayValue());
            }
     
            if (!glideElement.hasValue()) {
                continue;
            }
        }
    }
     
    //Remove an element from xmlDoc
    function removeElement(elName){
        var nn = xmlDoc.getElementByTagName(elName);
        if(nn && nn.parentNode) {
            nn.parentNode.removeChild(nn);
        }
    }
    //Add an element from xmlDoc
    function addElement(elName, elValue){
        xmlDoc.createElement(elName, elValue);
    }

    Image Removed

    UI Expand
    titleAlways share field
    Divbox
    stylebackground: white

    ServiceNow table maps abide by the share only updated fields property that is set in the dynamic share record. However, if you want to override this setting, you can do so in the table field map record.  This can be useful if you have a field that is designated as the record's unique ID field (such as the sys_id field) that you always want to share out, regardless of whether it's updated or not.

    Prerequisites:

    Instructions:

    In your sharing ServiceNow instance, go to Perspectium > Control and Configuration > Table Maps.
    Find and click the name of the table map that you want to modify.
    In the PSP Table Field Maps section, select the field that you want to always hare out regardless of the field being updated or not.
    Check the Always Share Field box.
  • Click Update.
  • Image Removed

    UI Expand
    titleHide empty fields
    Divbox
    stylebackground: white

    ServiceNow table maps will often generate common documents with empty elements, depending on the script that is used or the source field being mapped. This may not be the desired result and hiding these empty elements may be more favorable. This can be done using the hide empty fields feature that is built into table maps.

    Prerequisites:

    Instructions

    In your ServiceNow instance, go to Perspectium > Control and Configuration > Table Maps.
    Find and click the name of the table map that you want to modify.
    Check the Hide Empty Fields box.
  • Click Update.
  • Image Removed

    UI Expand
    titleField mappings in table maps
    Divbox
    stylebackground: white

    This feature allows you to map fields in the outbound record based on values from the ServiceNow record to be shared.

    Prerequisites:

    • Create a ServiceNow table map

    Instructions

    In your ServiceNow instance, go to Perspectium > Control and Configuration > Table Maps.
    In the PSP Table Field Maps section, click New.
    Alternatively, you can click Add all source table fields. This allows you to quickly add all fields of the specified source table as field maps. This can be useful for cases where you want all fields to be in the outbound table map and only want to modify a few fields to have different values.
    Image Removed
    Set the following required fields:
  • Set the Source Field with the name of the field in the source table
  • Set the Target Field with the name of the field in the target table
  • Click Submit.
  • Image Removed

    UI Expand
    titleUse script in field mappings
    Divbox
    stylebackground: white

    Using scripts, you an enhance or create new columns of data in your table map's field mapping.

    Here's how:

    Prerequisites:

    • Create a new field mapping

    Instructions

    In your ServiceNow instance, go to Perspectium > Control and Configuration > Table Maps.
    Find and click into the desired table map.
    In the PSP Table Field Maps section, click the desired field map.
    Check the Use Script box, which will reveal a Source Script field.
    Enter your script int o the Source Script field (find a few examples below)
  • Click Update.
  • Image Removed

    Examples

    There are various ways you can use scripting in your field mappings. Here are some examples:

    UI Expand
    titleSet mapping field value

    To set an overall value for your field mapping, use the following: 

    Code Block
    languagejs
    answer = ""; 
    UI Expand
    titleConversion to a new format

    To script the transformation of an entire record to a new format (ex: convert to a custom JSON format), use the current variable to reference values in the source record and set the answer variable to be the new value returned.

    The following example builds a JSON string from the value of correlation_id and short_description in the current record:

    Code Block
    var attributes = {"type":"Case"};
    var o = {};
    o.attributes = attributes;
    o.Id = current.correlation_id;
    o.Subject = current.short_description.toString();
    
    var j = new JSON();
    j = j.encode(o);
    
    answer = j.toString();
    
    UI Expand
    titleIgnore mapping fields

    To ignore mapping fields for cases such as specified conditions not being met, use the script: 

    Code Block
    languagejs
    ignore = true; 

    In the following example, the mapping field will be ignored if the the work_notes field is empty:

    Code Block
    languagejs
    if (current.work_notes == "") ignore = true; else answer = current.work_notes;