Send Servicenow data to external application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2017 02:26 AM
Hi ,
I have a requirement where I want to send open incidents from Servicenow to external application.
Can i send the limited number of records(say i have 1000 open incidents , i want to send 100 records at a time, so that they are sent over a loop.)
Also is this feasible that my Rest API gets called automatically whenever a new incident is opened. So that ,a new incident will also be sent to external application without making any further changes.
It will be great if any pointers are provided on this.
Thanks,
Monica
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2017 02:54 AM
Hi Ankur,
I want to send all open incidents to some external application(but in a set of 100 records). Also i want to make sure that whenever some new incident is created in servicenow, it should also be sent to external application.
Thanks,
Monica
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2017 03:36 AM
Hi Monica
Ok. Supposing you expose a web service externally and you set the information in ServiceNow following the information provided in this article
http://wiki.servicenow.com/index.php?title=Outbound_REST_Web_Service#gsc.tab=0
You can invoke the web service directly in service now using a business rule or any server side code (e.g. background script or script include)
Now because a server side code is executed locally to ServiceNow a query can obtain the list of incidents you want.
Using the usual GlideRecord you can do something like
ps. chooseWindow is used to paginate the query
var iStartLocation = 0;
var iEndLocation = 99;
var inc = new GlideRecord('incident');
inc.addQuery('active', true);
inc.chooseWindow(iStartLocation, iEndLocation);
inc.query();
while(inc.next){
try {
var r = new sn_ws.RESTMessageV2('YOUR WEB SERVER NAME', 'post');
r.setStringParameter('YOUR_WEB_SERVER_PARM_1', inc.number);
r.setStringParameter('YOUR_WEB_SERVER_PARM_2', inc.category);
//Other field here
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
}
catch(ex) {
var message = ex.getMessage();
}
}
The only annoying thing in this case is the fact we need to look into all the incidents and execute one REST message execution at time.
It is not like providing directly the entire list to your web service.
I hope this will help/answer your question and if it does mark it
Cheers
R0b0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2017 12:45 AM
Hi r0b0,
is there any way that i can update the script in Rest message itself.
I want to check for setRequestbody. i tried putting <content> in content section, but it didn't help. Can you provide any pointers on this.
var body = "<Message body content>";
r.setRequestBody(body);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2017 01:49 AM
Hi Monica
Could you please explain what you are trying to achieve ?
Other question. Did you set the outbound web service you need to call in service now ?
Cheers
R0b0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2017 02:34 AM
Hi R0bo,
I am trying to send data for few incidents (in one go )to my external application using setRequestBody(body).
yes i do have outbound webservice set . Initially i was trying to test it from outbound webservice console itself, but it seems business rule will serve me better.
Can business rule setup for one servicenow instance , be imported in other instances as well ?