Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

UI Steps


UI Step

Create a new script action

Log into your ServiceNow instance and navigate to System Policy > Events > Script Actions or simply type and then select Script Actions in the Filter Navigator on the upper left-hand side of the screen. Then, click New to create a new script action.


UI Step

Add an attachment.uploaded script

In the resulting Script Action form, type Perspectium Attachment (Ivanti) as the Name. Then, select attachment.uploaded from the Event name dropdown. Check the Active box. Then, add the script shown below in the scripting window and click Submit in the bottom left-hand corner of the form to save your script action.

Code Block
languagejs
themeEclipse
pspShareUploaded();
function pspShareUploaded() {
    var pspRepl = new PerspectiumReplicator();
    var pspUtil = new PerspectiumUtil();
    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 = "attach";
    var agr = new GlideRecord(event.table);
    agr.get(event.instance);
    if (pspUtil.recordHasTag(agr, "ivanti_sent")) {
        return;
    }
    var qc = new GlideRecord('psp_replicate_conf');
    qc.addQuery('table_name', tableName);
    qc.addQuery('action_create', true);
    qc.addQuery("action_update", true);
    qc.addQuery("sync_direction", "share");
    qc.addQuery("active", "true");
    qc.addQuery("u_target_queue.u_name", <TARGET_QUEUE_NAME_HERE>;
    qc.query();
    while(qc.next()) { 
        // reset the message set counter each time we do a new share configuration
        pspRepl.messageSetCounter = {};
            var        var startedDateTime = gs.nowDateTime();
                   // share record, setting tag to mark attachments
            if       if (tgr.operation() == "insert" || (tgr.isValidField("correlation_id") && tgr.correlation_id.nil())) {
                op           op = "deferred";
                   }
                  // try changing name from update to attach
            pspRepl       pspRepl.shareOneRecord(tgr, qc, tableName, op, 'ivanti_sent'); 
           }
    }