Since the transform map primarily handles corresponding actions in ServiceNow for actions initiated in Zendesk (i.e. when a user creates a ticket in Zendesk, the transform map will handle actually creating the ticket in ServiceNow after receiving it from the meshlet and MBS), ServiceNow can send back a .correlate message so Zendesk knows what the unique identifier (sys_id) of the record is in ServiceNow. In this case, you would create an onAfter transform script in the PSP Common Incident to Incident transform map with the following code to send back the .correlate message that the meshlet can process into Zendesk and save into the Correlation ID custom field: Code Block |
---|
| // Correlate sharing instance record
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var table_name = "incident"; // table being shared
var queue_name = "psp.in.meshlet.zendesk.incident.instance_name"; // queue that meshlet reads messages from
if(source.u_correlation_id != ""){
return;
}
var queueGR = new GlideRecord("u_psp_queues");
var queue = "";
queueGR.addQuery("u_name", queue_name);
queueGR.query();
if (!queueGR.next()){
return;
}
queue = queueGR.sys_id;
var shareGR = new GlideRecord("psp_replicate_conf");
shareGR.addQuery("table_name", table_name);
shareGR.addQuery("u_target_queue", queue);
shareGR.query();
if (!shareGR.next()){
return;
}
var tableGR = new GlideRecord(table_name);
tableGR.addQuery("sys_id", target.sys_id);
tableGR.query();
if (tableGR.next()){
var pspR = new PerspectiumReplicator();
pspR.shareRecord(tableGR, table_name, "correlate", shareGR.sys_id);
}
})(source, map, log, target); |
NOTE: By default the Zendesk meshlet will read any information in the <comments> field of the Common Incident sent back as part of the .correlate message when updating the Zendesk ticket with the ServiceNow sys_id. If you prefer to specify a default comment when no comments are entered, you can enter a default message to use in the defaultCorrelateResponse meshlet configuration.
|