Page History
HTML |
---|
<style> .release-box { height: 30px; width: 100px; padding-top: 8px; text-align: center; border-radius: 5px; font-weight: bold; background-color: #8efeb3; border-color: #FCE28A; } .release-box:hover { cursor: hand; cursor: pointer; opacity: .9; } </style> <meta name="robots" content="noindex"> <div class="release-box"> <a href="https://docs.perspectium.com/display/krypton" style="text-decoration: none; color: #FFFFFF; display: block;"> Krypton </a> </div> |
Anchor | ||||
---|---|---|---|---|
|
Once you are familiar with the basics of ServiceNow table maps, including the difference between inbound and outbound table maps, how to create a table map, and how to add a table map to bulk shares, there are optional features you can configure based on your needs.
Panel | ||||
---|---|---|---|---|
| ||||
|
Customize your target database schema using table maps
By default, data replicated from existing tables will automatically create the same schema at the replicated database. 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 your target database schema is done by using table maps in yourshare.
Here's how:
Instructions:
- In your sharing ServiceNow instance, go to Perspectium > Control and Configuration > Table Maps
- Select the table map you want to use (for the example, we'll use the table Incident to Common Incident), review the information in the fields, and check the Generate schema box.
WARNING: If there are multiple table maps with the same Target table name, the DataSync Agent will retrieve the first record when querying against ServiceNow for the schema.
NOTES:- Checking the Generate schema box is required in the initial sharing of your records
- The value specified in the Target table name field will be used as the name of the table in the database. When the DataSync Agent queries the instance for the table's schema, if it cannot find a table map with a matching Target table name, it will then look for a table that matches the value in the Type field instead.
To share the table map output, you need to crate a share and select the table map from step 1 in the Table map field. The generated payload can be subscribed by the DataSync Agent and the schema created dynamically.
In this example, the common_incident table map will result in the following table schema, if consumed by the DataSync Agent for MySQL.Code Block 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 |
---|
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. |
Use scripts to serialize records
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:
Variable | Description |
---|---|
current | This represents the record that is being shared |
gr_tablemap | This 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.
Example of a table map script
UI Expand | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
Field mappings in table maps
This feature allows you to map fields in the outbound record based on values from the ServiceNow record to be shared.
Prerequisites:
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. NOTE: With Krypton 8.1.0+, when using the Add all source table fields option or manually entering a new field, the Perspectium application will check if the source field exists in the source table (by checking if there is a field in the source table with the same field name) and set the Field Type and Field Length to match the source field as in the source table.
Set the following required fields:
Use script in field mappings
Using scripts, you an enhance or create new columns of data in your table map's field mapping. Here's how:
Prerequisites:
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)
Examples of using scripting in field mappings
There are various ways you can use scripting in your field mappings. Here are some examples (click to reveal):
title | Set mapping field value |
---|
To set an overall value for your field mapping, use the following:
Code Block | ||
---|---|---|
| ||
answer = ""; |
title | Conversion 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();
|
title | Ignore mapping fields |
---|
To ignore mapping fields for cases such as specified conditions not being met, use the script:
Code Block | ||
---|---|---|
| ||
ignore = true; |
In the following example, the mapping field will be ignored if the the work_notes field is empty:
Code Block | ||
---|---|---|
| ||
if (current.work_notes == "")
ignore = true;
else
answer = current.work_notes; |
Use field map as an attribute
To use a field as part of the outbound message attribute, do the following:
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 As Attribute box.
In the Target Field, start the field with the symbol @, i.e. @number.
Create filter conditions for a table map
This feature allows you to share data only when certain conditions are met. You can also set up filter conditions for dynamic shares and bulk shares. Table map filter conditions can be created per source field either with the ServiceNow condition builder or programatically. For more information about creating filter conditions in ServiceNow, see condition builder.
Here's how to create filter conditions for a ServiceNow table map:
In your sharing ServiceNow instance, go to Perspectium > Control and Configuration > Table Maps.Find and click into the table map that you want to configure.
Scroll down to the PSP Table Field Maps tab. Then, locate and click into the name of the source field that you want to create filter conditions for. You can create conditions for your source field either by typing a script in the scripting window or using the ServiceNow condition builder below the scripting window. For more information about creating filter conditions in ServiceNow, see condition builder.
Include embedded records in a table map
Embedded records are fields in the table map that cannot be mapped by singular values. Instead, they are entirely different records included (i.e. embedded) inside the table map to be created on the subscribing system.
To include embedded records for a ServiceNow table map, do the following:
In your sharing ServiceNow instance, go to Perspectium > Control and Configuration > Table Maps.Find and click into the table map that you want to configure.
Scroll down to the PSP Table Field Maps tab. Then, locate and click into the name of the source field that will contain the embedded record.
Update the Source Field to the following available:
approvers
${TM:psp_approver;sysapproval=$[GR:sys_id]}
${TM:psp_approver;document_id=$[GR:sys_id]}
Common Change
Common Request
Common Request Item
Common Knowledge
${TM:psp_attachment;table_sys_id=$[GR:sys_id]}
${TM:psp_attachment;table_sys_id=$[GR:sys_id];msp_client_application_sent;skip_insert}
${TM:psp_attachment;table_sys_id=$[GR:sys_id];msp_client_application_sent;psp_action=create}
Common Incident
Common Change
Common Problem
Common Request
Common Request Item
Common Task
Common Incident
Common Change
Common Request
Common Request Item
|
Field mappings in table maps
This feature allows you to map fields in the outbound record based on values from the ServiceNow record to be shared.
Prerequisites:
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. - 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
- Optionally, you can set the Field Type and Field Length fields if using the Generate Schema option mentioned above, the Use Script option to do scripting for this field map (see below) or select the Add CDATA Tags if the content of this field map should be wrapped for content that needs to be escaped for sharing out in XML i.e. <short_description><![CDATA[field value characters with markup]]></short_description>.
- Click Submit.
Use script in field mappings
Using scripts, you an enhance or create new columns of data in your table map's field mapping. Here's how:
Prerequisites:
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 into the Source Script field
- Click Update.
Example of using scripting in field mappings
There are various ways you can use scripting in your field mappings. Here is an example:
UI Expand | |||||
---|---|---|---|---|---|
| |||||
To set an overall value for your field mapping, use the following:
|
Click Update.
For other ways to utilize scripting in your field mappings, contact Perspectium Support.