---
title: "ServiceNow <> OpsRamp Integration (Legacy)"
canonical: "https://docs.perspectium.com/space/earlierReleases/1442170/ServiceNow%20%3C%3E%20OpsRamp%20Integration%20(Legacy)"
format: markdown
---
This i ntegration allows for replication of processes between your ServiceNow and OpsRamp.  This is a legacy feature so it has restricted permissions for Perspectium employees only - it is intended for internal use with customers on a need-by-need basis.  Update Sets To begin integrating SIAM for OpsRamp into your ServiceNow instance, you must first install the Perspectium update sets - request the download links from  support@perspectium.com .  The update sets should be installed in this order: Perspectium for ServiceNow update set Perspectium Common Doc to integrate (ie. Common Incident, Common Change, etc.) Once the update sets have been installed the Perspectium app in the ServiceNow menu should show the Remedy SIAM Integration tab: Dynamic Share and Shared Queue Creating a Shared Queue Click on the  shared queues  link under the  Replicator  tab in the Perspectium App Create a table with a shared queue named  psp.in.siam.client.opsramp  and pass in the respective credentials to the queue Click on this Shared Queue and verify that it is active. Stay in this Shared Queues view to complete the Dynamic Share and Shared queue configuration. To complete the configuration you will need: The SIAM endpoint url The Queue user for your SIAM endpoint. The Queue user password for your SIAM endpoint. You will then need to enter this information into the  Endpoint URL ,  Queue user , and  Queue user password  fields in the  psp.in.siam.client.opsramp  Shared queues. Once this is done, click  Update  in the top right of the shared queue view and these settings should be saved. Creating Dynamic Shares To create your own share for other tables click the Dynamic Shares module under the Perspectium application menu.  Click  New  to move on to the dynamic share form. Select the desired table to share and  check the  Active  box . Then, choose your trigger conditions and move to the   Additional Settings   section of the form. Select the table map that contains OpsRamp and the table name. Select the Target queue   psp.in.siam.client.opsramp . The following images are examples for configuring the ServiceNow incident table to share out to OpsRamp case object: Below is the code for the  Before share script : if (psp_action == 'update' && current.correlation_id == ''){
	psp_action = 'deferred';
} Outbound and Inbound Table Maps The inbound table map will handle the conversion of OpsRamp cases into ServiceNow incidents and the outbound table map will handle the conversion of ServiceNow incidents into OpsRamp cases. Both table maps are key components for the SIAM integration. Incident to Common Incident The outbound table map requires specific fields to communicate from ServiceNow Incidents to the OpsRamp cases. For each new table, a table map with the required outbound table map fields are necessary. The “@” designates date to the attribute field instead of going directly to the common data format. Below is an example of creating the field value that points correlation_id to @EndPointUrlPath, which will create a EndPointUrlPath attribute when sending out a message. Add more fields if necessary. The scripts used above are provided below: correlation_id to @EndpointUrlPath: answer = "";

if (current.correlation_id != "")
	answer = "/" + current.correlation_id;

answer += "?vtoken=your_token_here"; ProcessResponse to @ProcessResponse: answer = "true"; To properly share attachments, add the field map as shown below: source field: ${TM:psp_attachment;table_sys_id=$[GR:sys_id];msp_client_incident_sent} Attachments The  psp_attachment  table map below will map attachments into the  <attachments>  field when an incident message is shared out. Below is the script for the  data  field value: var sysEncodedAttachment = new GlideSysAttachment();  
var binData = sysEncodedAttachment.getBytes(current);  
var StringUtil = (typeof GlideStringUtil != 'undefined') ? new GlideStringUtil() : new Packages.com.glide.util.StringUtil();
answer = StringUtil.base64Encode(binData); Transform Map Unlike the outbound table map, we will be creating the transform table map which will convert the incoming fields and values for ServiceNow. Navigate to transform maps under System Import Sets with the filter navigator bar at the top left. Click  New  at the top left. Follow the example of the pictures below and add more fields if necessary. After creating and defining the field values, you need to add a few transform scripts so that ServiceNow will know how to handle, update, and where to direct values and attachments from received messages in the inbound table. Below is the onAfter transform script that will update deferred messages to have the correct correlation id and vtoken and also set the state to “Ready” so that the message can be sent out. Below will share out updated tickets after being received. Below will attach attachments respectively, from OpsRamp to ServiceNow. Script for deferred messages and updating correlation id: (function runTransformScript(source, map, log, target ) {
	var ogr = new GlideRecord("psp_out_message");
	var pspS = new PerspectiumEncryption();
	var StringUtil = (typeof GlideStringUtil != 'undefined') ? new GlideStringUtil() : new Packages.com.glide.util.StringUtil();
	ogr.addQuery("state", "deferred");
	ogr.addQuery("u_extra", 'CONTAINS', "number=" + source.u_number);
	ogr.queryNoDomain();

	while (ogr.next()) {
		var names = String(ogr.name).split(".");
		
		if (names.length != 2 || names[1] != "update"){
			continue;
		}
		
		var decodedValue = StringUtil.base64Decode(ogr.value);
		
		ogr.value = StringUtil.base64Encode(decodedValue.replace("<correlation_id/>", "<correlation_id>" + source.u_correlation_id + "</correlation_id>"));
		ogr.u_attributes = ogr.u_attributes.replace("EndpointUrlPath=/incidents", "EndpointUrlPath=/incidents/" + source.u_correlation_id);
		ogr.state = "ready";
		ogr.update();
	}
})(source, map, log, target); Script to share out updated tickets after being received: (function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
	
	if(source.u_number != ""){
		return;
	}
	
	var qgr = new GlideRecord("u_psp_queues");
	var queue = "";
	qgr.addQuery("u_name", "psp.in.siam.client.opsramp");
	qgr.query();
	if (!qgr.next()){
		return;
	}
	
	queue = qgr.sys_id;
	var qc = new GlideRecord("psp_replicate_conf");
	qc.addQuery("table_name", "incident");
	qc.addQuery("u_target_queue", qgr.sys_id);
	qc.query();
	if (!qc.next()){
		return;
	}
	
	var gr = new GlideRecord("incident");
	gr.addQuery("sys_id", target.sys_id);
	gr.query();
	if (gr.next()){
		var pspR = new PerspectiumReplicator();
		pspR.shareRecord(gr, "incident", "update", qc.sys_id);
	}
})(source, map, log, target); Script for attachments: (function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
	
	var attachments = new PerspectiumAttachment();
	attachments.addAttachments(source, target, "opsramp_sent");
	
})(source, map, log, target);