Before subscribe scripts
Before subscribe scripts are created with server-side JavaScript and will execute right before an insert or update allowing a 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 |
After subscribe scripts
After subscribe scripts are also created with server-side JavaScript and will run after an inbound (subscribed) 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) |
Prerequisites
First, you will need to configure a ServiceNow instance as a subscriber.
Create before/after subscribe scripts
To create a before/after subscribe script, follow these steps:
Log into a sharing ServiceNow instance that has another ServiceNow instance configured as a subscriber.
In the Filter Navigator on the upper left-hand side of the screen., navigate to Perspectium > Replicator > Subscribe.
Click the timestamp next to the name of the subscribe record you want to create a before/after subscribe script for.
Click the Filter and Enrichment tab. Then, scroll down to the After subscribe script window or the Before subscribe script window and start typing your script.
In the upper right-hand corner of the form, click Update to save your changes.