- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2020 02:50 AM
I am trying to create an incident in another ServiceNow instance using Rest Integration with Table API. and I am using Business Rule which will run after Incident created.
Incident is getting created in the target ServiceNow instance but it was not passing any values.
Here is the code that I have tried.
(function executeRule(current, previous /*null when async*/ ) {
var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://instance.service-now.com/api/now/table/incident?sysparm_display_value=all&sysparm_fields=number%2Cstate%2Cpriority%2Cshort_description');
request.setHttpMethod('POST');
//Eg. UserName="admin", Password="admin" for this code sample.
var user = 'admin';
var password = 'admin123';
var body = {
"caller_id":current.caller_id,
"priority" : current.priority,
"short_description":current.short_description
};
var requestBody = JSON.stringify(body);
request.setBasicAuth(user, password);
request.setRequestHeader("Accept", "application/json");
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestBody(requestBody);
var response = request.execute();
gs.log(response.getBody());
gs.addInfoMessage(response.getBody());
})(current, previous);
Could you guys help me to sort this out?
Thanks
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2020 03:00 AM
Hi Deepak,
If you log the "requestBody" variable does it contain all the values?
gs.info("requestBody: " + requestBody);
Also, as you are dot-walking it uses a reference to the object, so you could try using "current.getValue('variable_name');"
Let me know how you get on.
Thanks,
Dan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2020 03:00 AM
Hi Deepak,
If you log the "requestBody" variable does it contain all the values?
gs.info("requestBody: " + requestBody);
Also, as you are dot-walking it uses a reference to the object, so you could try using "current.getValue('variable_name');"
Let me know how you get on.
Thanks,
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2020 03:16 AM
Thanks Dan. 🙂
It is working when I set the values using getValue();