Click into the Salesforce Share Comment script action with an event name of incident.commented. Then, update the script as follows: pspShareUploaded();
function pspShareUploaded() { var pspRepl = new PerspectiumReplicator(); var pspUtil = new PerspectiumUtil(); var tableName = event.table; var tableSysId = event.instance; var tgr = new GlideRecord(tableName); tgr.addQuery('sys_id', tableSysId); tgr.queryNoDomain(); if (!tgr.next()) { return; }
var sgr = new GlideRecord("sys_journal_field"); sgr.addQuery("element_id", tableSysId); sgr.orderByDesc("sys_created_on"); sgr.query(); if (!sgr.next()) { return; }
if (pspUtil.recordHasTag(sgr, "salesforce_sent")) return; tgr.comments = sgr.value.toString();
var op = "comment"; 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.siam.client.salesforce"); 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 comments var pspC = new PerspectiumCorrelation(); var cgr = pspC.getCorrelationRecord(tgr, '', 'salesforce'); if (tgr.operation() == "insert" || (cgr == null || cgr.u_correlation_id == '')) { op = "deferred"; } // try changing name from update to comment pspRepl.shareOneRecord(tgr, qc, tableName, op, 'salesforce_sent'); }
} |
Then, click Update in the bottom left-hand corner of the form to save the changes to this script action. NOTE: The Salesforce Share Comment script action should have been initially set up when enabling the sharing of attachments and comments from ServiceNow to Salesforce. |