User Tools

Site Tools


Before/After Bulk Share Script


The “Before bulk share script” and “After bulk share script” sections allow you to specify a script that will run before the bulk share starts sharing out records and after the bulk share has completed sharing records. This can be useful for when you want to run a script using the Perspectium API to populate the bulk share with the sys ids of the records to be shared and/or create PSP outbound messages to send before the bulk share runs or after it is completed.

Both sections expect server side javascript, and is preconfigured with a globally available variable called bulkshare_gr that is the GlideRecord object corresponding to the bulk share configuration itself (i.e. you can use bulkshare_gr.u_name to access the name of the bulk share).

Canceling a bulk share in a before share script

The Before bulk share script section also allows you to cancel a bulk share from running if your script contains:

cancel = true;

That is, if after evaluating the script, there is a cancel variable and its value is set equal to true, then the bulk share will cancel from running. This may be useful for when you only want the bulk share to run if certain conditions are met and you prefer to create/check for these conditions using server side javascript instead of the condition builder.

Another example is when you have a ticket bulk share where you want to use the Share only Sys IDs listed feature and want to populate the sys id related list with sys ids of tickets that meet a query condition such as a state of open, you can write a script using the PerspectiumBulkShare API in the “Before bulk share script” as follows:

var pBS = new PerspectiumBulkShare(bulkshare_gr);
var tgr = new GlideRecord('ticket');
tgr.addQuery('state', '1');

When using the PerspectumBulkShare.addSysId() function and adding sys ids to the bulk share's sys id related list, only sys ids of the table specified in the bulk share should be added. The “Share only Sys IDs listed” feature only queries the table listed in the bulk share for these sys ids so if you specify sys ids of a different table they will not be found. In the above code sample, the bulk share is for the ticket table so you would only want to add sys ids of ticket records using PerspectiumBulkShare.addSysId().

snc_before_after_bulk_share_script.txt · Last modified: 2019/03/03 17:19 by timothy.pike