Script actions are server-side scripts triggered by events that can modify configuration items in your ServiceNow instance. The script action that you will need to edit in this step will create an outbound message for any incident records that have attachment data included, thus ensuring that any attachments you have uploaded in your ServiceNow incidents are successfully shared out to your Jira instance.


Procedure

To edit the Perspectium synchronize Jira attachment script action in ServiceNow for a multi-app ServiceBond integration, follow these steps:


Navigate to Script Actions

Log into your ServiceNow instance and navigate to System Policy Events Script Actions

Update the Perspectium synchronize Jira attachment script action

Click into the Perspectium synchronize Jira attachment script action with an event name of attachment.uploaded. Then, update the script as follows:

pspShareJiraUploaded();

function pspShareJiraUploaded() {
var pspRepl = new PerspectiumReplicator();
var pspCor = new PerspectiumCorrelation();

var tableName = event.parm1;
var tableSysId = event.parm2;

var tgr = new GlideRecord(tableName);
tgr.addQuery('sys_id', tableSysId);
tgr.queryNoDomain();
if (!tgr.next()) {
return;
}

var op = "update";

var cgr = pspCor.getCorrelationRecord(tgr, '', 'jira');
if (tgr.operation() == "insert" || cgr == null || (cgr && cgr.u_correlation_id == '')) {
op = "deferred";
}

var tUtils = new TableUtils(tableName);
var tables = tUtils.getTables().toString();
var tableStr = tables.substring(1, tables.length() - 1);

var qc = new GlideRecord('psp_replicate_conf');
qc.addQuery('table_name','IN', tableStr);
qc.addQuery("sync_direction", "share");
qc.addQuery("active", "true");
qc.addQuery("u_target_queue.u_name", "psp.in.siam.client.jira");
qc.query();
while(qc.next()) {
// reset the message set counter each time we do a new share configuration
pspRepl.messageSetCounter = {};

var startedDateTime = gs.nowDateTime();
// share record, setting tag to mark attachments
pspRepl.shareOneRecord(tgr, qc, tableName, op, 'jira_sent');
var finishedDateTime = gs.nowDateTime();

// send message set for each share configuration we send attachments for
pspRepl.pspMS.createMessageSetProcessed(pspRepl.messageSetCounter, qc, pspRepl.getKey(qc), startedDateTime, finishedDateTime);
}
}

Then, click Update in the bottom left-hand corner of the form to save the changes to this script action.

Next steps


Bond your ServiceNow incidents with Salesforce cases and Jira issues (multi-app integration)