Versions Compared

Key

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

UI Button
colormagenta
tooltipInformation on this page pertains to the Perspectium Fluorine release
titleFluorine
urlhttps://docdocs.perspectium.com/display/fluorine


To ensure that the data being shared out of Ivanti and into ServiceNow (inbound data) is being mapped correctly when arriving at your ServiceNow instance, you will next need to add and update some of the scripts in the PSP Common Incident to Incident transform map under the PSP Common Transform Maps module. ServiceNow transform maps handle the format of data being shared into a ServiceNow instance. Making changes to the transform map scripts will allow data to be properly shared out of Ivanti Service Manager and then be mapped correctly to the relevant fields in ServiceNowServiceNow script actions are server-side scripts triggered by events that can modify configuration items in your instance. The script action that you will need to add will create a ServiceNow outbound message for any incident records that have attachment data included, thus ensuring that any attachments you have created in ServiceNow are successfully shared out to Ivanti Service Manager.


Prerequisites


(warning) First, you will need to create a ServiceNow dynamic share for Ivanti.

(warning) You will also need to create a ServiceNow subscribed queue and subscribe for Ivanti and edit ServiceNow outbound table map fields for Ivanti.

Procedure

To (warning) Lastly, you will need to add and edit the PSP Common Incident to Incident ServiceNow transform map scripts for Ivanti.

Procedure

To add a ServiceNow attachment.uploaded script action for Ivanti, follow these steps:


Add scripts for additional table map fields

Using Step #3 as a guide, click into and then add Source Scripts for the table map fields per the information in the table shown below.

UI Steps
UI Step
Access the Incident to PSP Common Incident transform map

Create a new script action

Log into your ServiceNow instance and navigate to System Import SetsPolicy > AdministrationEvents > Transform MapsScript Actions or simply type and then select Transform MapsScript Actions in the Filter Navigator on the upper left-hand side of the screen. Then, search for and then click into the PSP Common Incident to Incident transform mapclick New to create a new script action.

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
    var pspS = new PerspectiumEncryption();
    var pspR = new PerspectiumReplicator();
    var ogr = new GlideRecord("psp_out_message");
    ogr.addQuery("state", "deferred");
    var orQc = ogr.addQuery("u_extra", "CONTAINS", "number=" + source.u_number);
    orQc.addOrCondition("u_attributes", "CONTAINS", target.sys_id);
   ogr
UI Step

Add

transform scripts

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.

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", "psp.in.meshlet.ivanti");
    qc

Scroll down to the tabs at the bottom of the form and click the Transform Scripts tab. Create New transform map scripts according to the information in the table shown below.

WhenOrderScript
onBefore80
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
 if (source.u_comments.nil())
  return;
 var sgr = new GlideRecord("sys_journal_field");
 sgr.addQuery("name", target.getTableName());
 sgr.addQuery("element", "comments");
 sgr.addQuery("element_id", target.sys_id);
 sgr.addQuery("value", source.u_comments);
 sgr.query(); 
 if (sgr.next())
  ignore = true;
})(source, map, log, target);
onBefore85
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
 if (source.u_caller_email.nil()) {
  return; 
 }
 var gr = new GlideRecord("sys_user");
 gr.addQuery("email", source.u_caller_email);
 gr.query(); 
 if (gr.next()) {
  target.caller_id = gr.sys_id;
 }
})(source, map, log, target);
onAfter90
.query();
    while
(
ogr
qc.next()) { 
 
       // reset 
update
the 
value
message 
with
set 
correlation
counter 
id
each 
before
time we 
send
do 
out
a 
       var
new 
decodeData
share 
=
configuration
 
pspS.decryptString(ogr.value);
        decodeData = decodeData.replace("<correlation_id/>", "<correlation_id>" + target.correlation_id + "</correlation_id>");
        if (decodeData.indexOf("</attachments>") > -1) {
            ogr.name = ogr.name.replace("update", "attach");
        }
        ogr.value = pspS.encryptStringWithCipher(decodeData, "3");
        ogr.u_extra = "";
        ogr.state = "ready"; 
        ogr.update();
    }
})(source, map, log, target);
onAfter95
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
 if (!source.u_correlation_id.isNil()) {
        return;
    }
    var pspR = new PerspectiumReplicator();
    var ds = new GlideRecord("psp_replicate_conf");
    ds.addQuery("u_target_queue.u_name", "psp.in.meshlet.ivanti");
    ds.addQuery("active", "true");
    ds.addQuery("sync_direction", "share");
    ds.query();
    if (!ds.next()) {
        return;
    }
    var gr = new GlideRecord("incident");
    gr.addQuery("sys_id", target.sys_id);
    gr.query();
    if (gr.next()) {
        pspR.shareRecord(gr, "incident", "update", ds.sys_id);
    }
})(source, map, log, target);
UI Step
Table Map Source FieldScript to add(info) NOTE: Field values will be reflected in Ivanti in...
description
answer = current.description;
if (current.description.nil()) {
 answer = current.short_description;
}
Summary
business_service
answer = “Service Desk”;
Service
category
answer = “Capacity”;
Category
state
answer = “Active”;
Status
assigned_to
answer = “Alan Taylor”;
Owner
assignment_group
answer = “Service Desk”;
Team
UI Step

Edit the onAfter script with Order 110

In the list of Transform Scripts, search for and click into the onAfter script with an Order of 110. Scroll down to the scripting window and replace "msp_client_incident_sent" with "ivanti_sent"

Finally, click Update in the bottom left-hand corner of the form to save the changes to your transform map script.

Next steps

Add ServiceNow attachment.uploaded script action for Ivanti
       pspRepl.messageSetCounter = {};
            var startedDateTime = gs.nowDateTime();
            // share record, setting tag to mark attachments
            if (tgr.operation() == "insert" || (tgr.isValidField("correlation_id") && tgr.correlation_id.nil())) {
                op = "deferred";
            }
           // try changing name from update to attach
            pspRepl.shareOneRecord(tgr, qc, tableName, op, 'ivanti_sent'); 
        }
    }




Similar topics


Content by Label
showLabelsfalse
max5
showSpacefalse
sortmodified
cqllabel = "ivanti" and space = currentSpace()