User Tools

Site Tools


ServiceNow to Salesforce Configuration

The ServiceNow to Salesforce integration allows for replication of data between ServiceNow and Salesforce.

Below are step by step configurations of both systems, using an integration of ServiceNow incidents and Salesforce cases as an example.

Update Sets

Click here for a guide on how to install update sets on ServiceNow. If you have not received the respective update sets mentioned, please contact our support so they may assist you. Below are the necessary update sets for integrating ServiceNow to Salesforce.

Update Sets
Perspectium for ServiceNow Core
Perspectium Salesforce

Table Map

In order to properly share out records from ServiceNow tables to Salesforce objects, outbound table maps will need to be created that shares out JSON as can be read by Salesforce.

Incident to SFDC Case

Because we're going from incident on ServiceNow to case on Salesforce, the target table name will be set to “Case” and data will be passed in as a JSON.

You may also send Incident comments from ServiceNow to the Salesforce CaseComment table or even attachments in general. Refer to the pages below in order to do so.

ServiceNow Salesforce Attachments

ServiceNow Salesforce CaseComment

ServiceNow Salesforce Content Version

Incident to SFDC Case:

Below are mappings for values from ServiceNow to Salesforce. “snn_c” is an example of a custom field. The custom field is a custom object that will be created on Salesforce in which the number will be passed into. In this case, the custom object is snn_c, which may be named differently by the user. The other fields are required.

Below are the source script for required fields above:




answer= {"type":"Case"};


if(current.correlation_id != null && current.correlation_id != "")
	answer = current.correlation_id.toString();



Dynamic Share

After setting the table maps, dynamic share may now properly be able to reference them. The following images are an example for configuring the ServiceNow incident table to share out to Salesforce case object. Here is also a guide for how to set up a dynamic share.

Before share script:

if (psp_action == 'update' && current.correlation_id == ''){
	psp_action = 'deferred';

Import Set Table

By default, the import set table, u_sfdc_case, is provided by the update set to read in records passed from Salesforce into ServiceNow.

Transform Maps

The u_sfdc_case transform map creates the integration between Salesforce case to ServiceNow incident table. The following fields below are required for the integrations to be made. The snn__c is to be replaced by the custom object created on Salesforce by the user.

Set coalesce in the custom object to true. This will create a record if it is nonexistent.

Transform Scripts

The following transform scripts must be saved in the transform maps, as mentioned previously, and will take affect once messages from Salesforce are received in ServiceNow. They will share out the incident numbers, and deferred records and attachments once the record has received its' correlation ID.

onAfter script to share out deferred records:

var ogr = new GlideRecord("psp_out_message");
var pspS = new PerspectiumEncryption();
ogr.addQuery("state", "deferred");
//replace source.u_snn_c with correct variable
ogr.addQuery("u_attributes", 'CONTAINS', "ExternalIdValue=" + source.u_correlation_display_c);
var jsonParser = new JSONParser();

while ( {
	var cipher;
	if (ogr.u_attributes.indexOf("cipher=2") > -1)
		cipher = "2";
	else if (ogr.u_attributes.indexOf("cipher=4") > -1)
		cipher = "4";
		cipher = "3";
    var names = String(".");
    if (names.length != 2 || names[1] != "update") {

    var decoded = pspS.decryptStringWithCipher(String(ogr.value), cipher);
    var newValue = jsonParser.parse(decoded.toString());
    var att = ogr.u_attributes.toString();

    if (att.indexOf(target.sys_id) < 0)
    if (names[0] == 'Attachment' || names[0] == 'CaseComment') { = names[0] + '.insert';
        newValue.ParentId = source.u_id.toString();
    } else if (names[0] == 'Case')
        newValue.Id = source.u_id.toString();


    var str = JSON.stringify(newValue);
    ogr.value = pspS.encryptStringWithCipher(str, cipher);
    ogr.u_extra = "";
    ogr.state = "ready";


onAfter script to share out ServiceNow incident numbers to Salesforce:

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
	// replace source.u_snn_c with your custom object
	if(source.u_snn_c != ""){
	var qgr = new GlideRecord("u_psp_queues");
	var queue = "";
	//enter queue in replace here
	qgr.addQuery("u_name", "REPLACE_HERE");
	if (!{
	queue = qgr.sys_id;
	var qc = new GlideRecord("psp_replicate_conf");
	qc.addQuery("table_name", "incident");
	qc.addQuery("u_target_queue", qgr.sys_id);
	if (!{
	var gr = new GlideRecord("incident");
	gr.addQuery("sys_id", target.sys_id);
	if ({
		var pspR = new PerspectiumReplicator();
		pspR.shareRecord(gr, "incident", "update", qc.sys_id);
})(source, map, log, target);

For this script, make sure to enter your queue and custom object into the designated areas.

Script Action

The script action is provided by default. It will fire once attachments are made to an incident record.


Below are the required subscribes so that your instance may effectively receive data. Copy exactly as is.



servicenow_salesforce_configuration.txt · Last modified: 2020/06/16 17:53 by vinhn