UI Step |
---|
Log into your ServiceNow instance and navigate to Perspectium Common Documents > PSP Common Transform Maps. Click into the PSP Common Incident to Incident transform map and click Copy in the upper right-hand corner of the form to copy the transform map. Then, click into the copied table map and rename it to PSP Common Incident to Incident (Salesforce) and click Update to save your changes. |
UI Step |
---|
Make sure that the Run business rules box is checked. Then, scroll down to the Field Maps tab. |
UI Step |
---|
Within the list of field maps, locate and then click into the field map with a target field of sys_id. Then, add the following Source script: answer = (function transformEntry(source) { var pspC = new PerspectiumCorrelation(); return pspC.getRecordSysId(source, 'salesforce', 'incident'); })(source); |
Finally, click Update in the bottom left-hand corner of the form to save your changes. |
UI Step |
---|
Scroll down and click the Transform Scripts tab. Edit two transform scripts by clicking into them and using the updated scripts as follows (Be sure to click Update to save your changes to each transform script): Script begins with | Updated script | //comments | //comments - Prevent looping when comments are posted (function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var pspUtil = new PerspectiumUtil(); var elementId = target.sys_id;
if (source.u_comments.nil()) return;
var tgr = new GlideRecord("sys_journal_field"); tgr.addQuery("element_id", elementId); tgr.orderByDesc("sys_created_on"); tgr.query(); if (tgr.next()) { if (pspUtil.recordHasTag(tgr, "salesforce_sent")) { return; } pspUtil.addTag(tgr, "salesforce_sent"); }
})(source, map, log, target); | //deferred | //deferred - Reprocess messages that has not been e-bonded (function runTransformScript(source, map, log, target /*undefined onStart*/ ) { var igr = new GlideRecord("incident"); igr.addQuery("sys_id", source.sys_target_sys_id); igr.query();
var ogr = new GlideRecord("psp_out_message"); var pspS = new PerspectiumEncryption(); ogr.addQuery("state", "Deferred"); ogr.addQuery("u_extra", 'CONTAINS', "number=" + igr.number); ogr.addQuery("u_target_queue.u_name", "psp.in.siam.client.salesforce"); ogr.queryNoDomain();
while (ogr.next()) { var att = ogr.u_attributes.toString(); if (att.indexOf(target.sys_id) < 0) continue;
var cipher; if (ogr.u_attributes.includes("cipher=3")) cipher = "3"; else cipher = "2";
var decodeData = pspS.decryptString(ogr.value); decodeData = decodeData.replace("<correlation_id/>", "<correlation_id>" + source.u_sys_id + "</correlation_id>"); decodeData = decodeData.replace("<correlation_display/>", "<correlation_display>" + source.u_number + "</correlation_display>");
var name; if (decodeData.includes("</comments>")) name = "common_incident.comment"; else if (decodeData.includes("</attachment>")) name = "common_incident.attachment"; else name = "common_incident.insert";
ogr.name = name; ogr.u_extra = ""; ogr.state = "ready"; ogr.value = pspS.encryptStringWithCipher(decodeData, cipher); ogr.update(); } })(source, map, log, target); |
|
UI Step |
---|
Create three new transform scripts by clicking New and adding the following specifications for each (Be sure to click Submit to save each new transform script): When | Active checked? | Order | Script |
---|
onBefore | Yes | 90 | // Ignore apps other than Salesforce (function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
if (!source.u_provider.toString().contains("salesforce")) { ignore = true; }
})(source, map, log, target); | onAfter | Yes | 90 | // Update correlation IDs in the Correlation table (function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
if (source.u_provider.toString().contains("salesforce")) { var pspC = new PerspectiumCorrelation(); pspC.updateCorrelationRecord(target, source, 'salesforce'); }
})(source, map, log, target); | onBefore | Yes | 105 | // Prevent duplication of comments (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); |
|
UI Step |
---|
Click Update in the top right-hand corner of the transform map form to save your changes to the PSP Common Incident to Incident (Salesforce) transform map. |
|