Enhance your DataSync for ServiceNow experience with table maps by using the following configurations:


Adding to the Attributes

To map a field to the Attributes field of the DataSync for ServiceNow outbound message, you will need to use the value, @.

In the Target field, specify the following:

@name

This will create a name = value in the Attributes field.

For example, if you want the name field to map to a title attribute, you can specify name as the Source Field and @title as the Target Field. The resulting attribute will have title = value, where value is the name's value. This will be stored into the attributes field of the outgoing message.

Resolving a field using another table map

Sending Attachments

You can have a field be mapped such that it resolves to and represents the output of another table mapFor example, you can create an incident table map that will query to get a record's attachments and add it to its outbound record by creating the following field map:

Where the Target Field has a value of attachments and the Source Field has a value of:

${TM:psp_attachment;table_sys_id=$[GR:sys_id]}

The Source Field breaks down as follows:

FieldDescription
TMThe field is mapped to another table map
psp_attachment

The name of the other table map to use

table_sys_id=$[GR:sys_id]An optional query to limit the records returned where the query is based on fields of the other table map. In this case, we are using the the sys_id of the current GlideRecord (incident) being table mapped so that we only get its attachments in the psp_attachment table map. Since the sys_attachment table is being used in the psp_attachment table map as the source table, we do so by looking for records in sys_attachment with a table_sys_id of the incident record's sys_id.
(Optional) limit nLimits to sending only n attachments per message (such as limit 1). Refer to Setting Individual Attachments Replication below.

In the psp_attachment table map, the psp_attachment table contains the source table we want to query for table mapped data (sys_attachment) and like any other table map, the Target Field represents the parent element of a record after its been mapped and the fields are the fields we want in the output data. A psp_attachment table mapped record would look as follows:

<attachment>
   <file_name>test.png</file_name>
   <size_bytes>23453</size_bytes>
</attachment>

By creating a field map in our incident table map that maps to the psp_attachment table map, the psp_attachment table map's data will then be stored as a child of the field map's target field “attachments” as follows:

<common_incident>
    <attachments>
        <attachment>
           <file_name>test.png</file_name>
           <size_bytes>23453</size_bytes>
        </attachment>
    </attachments>
</common_incident>

In the above field map, representing another table map feature will log an error and not add the other table map if it resolves to a value greater than the outbound bytes properties for sending outbound messages or greater than 16MB. This is to account for ServiceNow 16MB limit for querying for a field's value.

(info) NOTE: Anything over 16MB will cause an error of:

java.lang.RuntimeException: String object would exceed maximum permitted size

In the above example, if the psp_attachment table map was greater than the outbound bytes properties or 16MB, no value would be added for <attachments> into the <common_incident> table map.

Setting Individual Attachments Replication

In cases where only one attachment is to be sent per outbound message, the limit n parameter in the embedded table map helps us achieve this.

The following steps describe what needs to be set up:


Add the limit 1 parameter to the psp_attachment embedded table map as follows: 

${TM:psp_attachment;table_sys_id=$[GR:sys_id];siam_sent;limit 1}

Verify that the siam_sent tag exists in your system. Tags is what prevents attachments from being sent every time. Go to the Tags table (label.list) and create a tag with name siam_sent if it does not exist.

In your Before Share Script of your dynamic share, we will make a function call to send them individually:

 // sending attachments added before submitting ticket for the first time
if (!ignore && current.operation() == "insert") {
    var tableMap = share_gr.u_table_map;
    new PerspectiumAttachment().sendIndividualAttachments(current, "deferred", "siam_sent", share_gr, '', tableMap);
}
Related Records

Embedded table maps can be used to uphold related records in ServiceNow. This will allow users to embed child records into the parent payload to be restored on the receiving instance.

Example 

<common_incident>
       <problems>
             <problem>
                 <short_description>Problem Example</short_description>
                 <assignment_group_name/>
                 <id>7299dbc5db22230071f25421cf9619c1</id>
                 <assigned_to_name/>
                 <state>1</state>
                 <number>PRB0040104</number>
             </problem>
      </problems>
</common_incident>

See Common Documents for more examples.