- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2020 10:10 PM
Hello all. Long time lurker, first time poster!
To start with, I appreciate everything I've been able to take in over the years. It's only because of this Community that I'm at the point I am now, and whilst that is a "point" of trouble I'm appreciative that I'm at a place of asking for help.
Long story short, I'm working to set up a ServiceNow to ServiceNow integration. What I've currently done;
- On target instance, table has been created, extends import set, necessary fields populated, transform map built
- On target instance, REST user has been created, roles provisioned correctly, validated with REST API EXPLORER that user can provision new tickets
- On source instance the Outbound REST message has been created for a POST to the staging table, the "CONTENT" block of the HTTP request is populated with variables
- On source instance, a business rule has been created to run "ON INSERT" to Incident table in source. It replaces the variables of the HTTP request block with the ticket information and sends it, as well as captures the response and logs information from target instance into the ticket on source instance.
So far EVERYTHING is working except I cannot gather the SYS_ID and NUMBER from the response. Below is the code from my business rule. I'm definitely weak on this subject matter but working to correct that. In checking the syslog I see a few lines of entry that indicate "org.mozilla.javascript.EcmaError: Empty JSON string" so I'm pretty sure my issues reside in parsing the JSON.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var request = new sn_ws.RESTMessageV2("Target ServiceNow Instance", "create_incident");
request.setStringParameterNoEscape("presincnum", current.number);
request.setStringParameterNoEscape("presincsys", current.sys_id);
request.setStringParameterNoEscape("abrincnum", current.u_client_incident_number);
request.setStringParameterNoEscape("shodes", current.short_description);
request.setStringParameterNoEscape("des", current.description);
request.setStringParameterNoEscape("incsta", current.incident_state);
request.setStringParameterNoEscape("imp", current.impact);
request.setStringParameterNoEscape("urg", current.urgency);
request.setStringParameterNoEscape("pri", current.priority);
request.setStringParameterNoEscape("connam", current.caller_id.name);
request.setStringParameterNoEscape("conema", current.caller_id.email);
request.setStringParameterNoEscape("conite", current.cmdb_ci);
request.setStringParameterNoEscape("addcom", current.comments);
request.setStringParameterNoEscape("rescod", current.close_code);
request.setStringParameterNoEscape("resnot", current.close_notes);
request.setStringParameterNoEscape("respar", current.u_sync_ticket);
var response = request.execute();
var requestBody = request.getRequestBody();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
parsedJSON = JSON.parse(responseBody);
var result = parsedJSON["result"];
var targetTicNumber = result[0]["display_value"];
var targetSys_id = result[0]["sys_id"];
current.u_client_sysid = targetSys_id;
gs.log(targetSys_id);
})(current, previous);
Solved! Go to Solution.
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2020 07:43 AM
The last thing I can think of would be to perhaps execute the process using credentials with admin and see if that makes any difference. If it does, it might be a role or something getting in the way. If it doesn't work with admin, I'd review the logs on your target instance. Maybe an error is occurring that doesn't stop the record creation, but stops the response?
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2020 09:51 AM
No apologies needed! Definitely a huge assist!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2020 07:03 AM
last try
gs.log(parameterArr.result[0].display_value);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2020 10:20 AM
So I've gone through and added a number of roles to the Integration_User. After adding several I was able to get this to work. I then stripped them away until I was left with the following;
Roles List
import_admin
u_incidents_for_rest_user
I've not done EXTENSIVE testing but I would imagine that this is all that is needed if you are doing a ServiceNow to ServiceNow integration and using custom tables that extend the Import Set Table. I'm able to now create tickets on the TARGET and I can instantly produce the ticket number and SYS ID on the SOURCE system.
Thanks