User Tools

Site Tools


snc_table_maps

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
snc_table_maps [2018/09/05 22:48]
paul [Get Display Value]
snc_table_maps [2019/02/05 13:31] (current)
javier.valerio
Line 188: Line 188:
   * **psp_attachment** - The name of the other table map to use   * **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.   * **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.
 +  * **limit n** (optional) - Limits to sending only n attachments per message (such as limit 1). Refer to "//​Setting Individual Attachments Replication//"​ below.
  
 The psp_attachment table map then looks as follows: The psp_attachment table map then looks as follows:
Line 215: Line 216:
  
 So 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. So 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:​
 +
 +    <code javascript>​
 +    ...
 +    // 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);
 +    }
 +    </​code>​
 +
  
 ===== Further Examples ===== ===== Further Examples =====
 +
 +
 +==== 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. ​
 +
 +{{:​embedded_problem.png?​1000|}}
 +
 +<​code>​
 +<​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>​
 +</​code>​
 ==== Conversion to a New Format ==== ==== Conversion to a New Format ====
 To script the transformation of an entire record to a new format (ex: convert to a custom JSON format), select the ''​Use Script''​ checkbox on the Table Map configuration form.  This will display a Script input that will execute a script instead of using individual field mappings. ​ 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: To script the transformation of an entire record to a new format (ex: convert to a custom JSON format), select the ''​Use Script''​ checkbox on the Table Map configuration form.  This will display a Script input that will execute a script instead of using individual field mappings. ​ 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:
snc_table_maps.1536212919.txt.gz ยท Last modified: 2018/09/05 22:48 by paul