Versions Compared

Key

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

To ensure that the data being shared out of Zendesk 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 transform maps 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 Zendesk and then be mapped correctly to the relevant fields in ServiceNow.


Procedure

To add and edit the transform map scripts for Zendesk, follow these steps:


UI Steps


UI Step

Access the transform map

Log into your ServiceNow instance and navigate to Perspectium Common Documents > PSP Common Transform Maps or simply type and select Transform Maps in the Filter Navigator on the upper left-hand side of the screen. Then, search for and then click into the following transform map:

TableTransform Map
Incident

PSP Common Incident to Incident



UI Step

Add and update field maps 

The transform maps comes with default mappings you can modify as needed. 

By default, Zendesk does not provide display names for user fields such as the person who was assigned a ticket. Instead, it will be mapped with their ID such as:

Code Block
languagexml
<assigned_to_name>7603423341591</assigned_to_name>

So in this case you will want to map this value in the field map to a corresponding value for a user in ServiceNow.

Click Update to save your changes.


UI Step

(Optional) Correlate when a Zendesk ticket is first created in ServiceNow

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 on 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
languagejs
// 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);

(info) 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 specify enter a default message to use in the defaultCorrelateResponse meshlet configuration.


UI Step

(Optional) Add a comment when a ticket is successfully created in Zendesk

When the Zendesk the  meshlet creates a new ticket in Zendesk, it will send back a .correlate message that ServiceNow can consume and add a comment to the incident. For example, you can create an onAfter transform script on the PSP Common Incident to Incident transform map with the following code to log the ID of the record as created in Zendesk:  

Code Block
languagejs
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

	// Add your code here
	if (source.u_action == 'correlate') {
		var igr = new GlideRecord('incident');
		igr.query('sys_id', source.u_correlation_id);
		if (igr.next()) {
			igr.comments.setJournalEntry('Record successfully created in Zendesk with ID ' + source.u_sys_id);
			igr.update();
		}
	}
})(source, map, log, target);