Here are the ways in which you can use the Subscribe module to configure your ServiceNow subscribe instance.
Global subscribe is a Subscribe definition that when created, will allow all incoming messages to be subscribed. If there is an existing subscribe definition for a specific table, its definition will override the global definition. |
Once you have configured a ServiceNow instance as a subscriber, you can use before/after subscribe scripts to customize how the data will be consumed and stored in your subscribing ServiceNow instance.
These scripts are created with server-side JavaScript and will execute right before a record insert or update, allowing the chance to modify the record before persisting. Within your before subscribe script, you have access to the following variables:
Variable | Description |
---|---|
current | Record that is being inserted or updated |
repl_gr | Temporary inbound record. Will be mapped to repl_gr by default. |
gr_before | Record before any update is made to it. If the record doesn't exist (i.e., for an insert), then this variable will be assigned to current. |
qcurrent | Record within the psp_in_message table (pulled from the Perspectium Mesh). Use the message's key value to determine its source. |
ignore | Can assign a value of true in order to stop the execution of the subscribe |
qcurrentxml | Holds the xml object of the inbound record |
xml_util | Holds an xml utility for working with qcurrentxml |
These scripts are also created with server-side JavaScript and will execute right after a record from a sharing instance is synced on the subscribing instance. Within your after subscribe script, you have access to the following variables:
Variable | Description |
---|---|
current | Record that was inserted, updated or deleted, the destination record |
qcurrent | Record within the psp_in_message table (pulled from the Perspectium Mesh). Use the message's key value to determine its source. |
qcurrentxml | Holds the xml object of the inbound record |
xml_util | Holds an xml utility for working with qcurrentxml |
subscribe_gr | Holds the GlideRecord object corresponding to the subscribe record configuration itself (You can use subscribe_gr.getTableName() to access the name of the table you're trying to insert) |
Here's how to create these scripts:
Examples of before and after subscribe scripts
Below are some examples of scripts you can use to achieve specific results:
|
|
|
|
|
|
|
|
|
This feature is useful in cases when your sharing application has custom fields that do not typically exist in ServiceNow table schemas. Enabling the feature will ensure that any custom or outlying fields in your source instance are properly synced in your subscribing instance by inserting missing fields.
|
Here's how to sync all source fields with the fields in your subscribing ServiceNow instance: