How to send data to third party application from servicenow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2022 01:13 AM
Hi all,
Please guide me on how to send data from the custom tables to other application, using the web services / REST API.
Requirement is to send some of the fields information from the custom tables in a JSON Format on a weekly basis(Every friday 6.00PM IST).
Please guide me the steps to follow to achieve this.
Thank you,
Balaram.
- Labels:
-
Incident Management
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2022 03:26 AM
Hi Balaram,
You can write a Scheduled script.use this script make changes as per your requirement :
try {
//Send REST get to grab json blob
var r = new sn_ws.RESTMessageV2('noc.sd343.com Data Center List', 'get');
r.setStringParameter('Accept', 'application/json');
r.setStringParameter('key', 'Private');
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.log("Response Body " + responseBody);
var parser = new JSONParser();
var parsed = parser.parse(responseBody);
gs.log("Parsed JSON" + parsed);
/*for (var n in parsed.value[0]){ //use this to see your json objects
gs.log("Parsed[" + n +"]= " + parsed.value[0][n]);
}*/
gs.log(parsed);
}catch(ex) {
var message = ex.getMessage();
}
//Create a new import set
var crImpSet = new GlideRecord('sys_import_set');
crImpSet.initialize();
crImpSet.mode = 'synchronous';
crImpSet.table_name = 'u_fnf_import_data_centers'; //Set the extended importset table
crImpSet.state = 'loading';
crImpSet.insert();
var locs = parsed.value;
gs.log("Parsed Array Size locs = " + locs.length);
var restGR = new GlideRecord('u_fnf_import_data_centers'); //Query extended import set rows table
//Loop through the json chunks until 0 remain creating import set rows to be transformed
for (var i = 0; i < locs.length; i++) {
restGR.initialize();
restGR.u_description = locs[i].description;
restGR.u_key = locs[i].key;
restGR.u_id = locs[i].id;
restGR.sys_import_set = crImpSet.sys_id; //This is the sys_id from import set above
restGR.insert();
}
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2022 05:17 AM
Hi,
There is a very good article present on how to do this using Rest. Please follow the step by step procedure explained here.
https://community.servicenow.com/community?id=community_article&sys_id=30f8a1631b5c4910cd3b33bc1d4bcbbf
Only thing you need to change is once all steps are done, you need to add below additional steps as well to fire it daily at a time you need .
Navigate to the module "Today's Scheduled Job" as shown below:
Configure the form as below:
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke