User Tools

Site Tools


This is an old revision of the document!

Before Share Script


A before share script allows the current record that is being shared to be processed after it is loaded into a GlideRecord, but before it is encrypted and queued up to the Perspectium Cloud Server. This feature is available for both Dynamic Share and Bulk Share.

The script expects server side javascript, and is preconfigured with a globally available variable called current that is the GlideRecord object that is going to be shared.

For example, to ensure that the short_description field value of a record to always be greater than 0 and less than 1000 characters, you may use the following script:

var s = current.short_description.toString();
current.short_description = s.substring(0, 1000);

Because this script is executed every time a record is shared, be aware of the processing delays introduced that will be multiplied when sharing multiple records at the same time.

Note if you have multiple share configurations for the same table (such as different share configurations that each have a different target queue), any changes to the current object may affect any conditions you have to share since this same current object is referenced as we iterate through the table's different share configurations.

For example, if you have multiple share conditions for the ticket table (one will share to the target queue psp.out.servicenow.test and the other shares to the queue and all have the condition short_description is 'test' in order to share records, if one of your share configurations has the before share script of: current.short_description = 'test123'

Then other share configurations for this will not share the record to their target queues since the short_description of the current object has been changed to 'test123'.

before_share_script.1443828837.txt.gz · Last modified: 2015/10/02 16:33 by carlos