Correlating Request sys_id and Request Item sys_id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2015 05:50 AM
Hello,
My experience with the ServiceNow REST API is fairly limited, so forgive me if this is obvious or documented somewhere, but I'm having difficulty correlating Request sys_ids and Request Item sys_ids. Ideally I'd like to be able to perform a query against the REST API using a Request sys_id and return the child(ren) Request Item sys_id(s). What happens right now is a user will request a service which kicks off a workflow with IBM Cloud Orchestrator (ICO) and generates a Request Item. The Request Item is visible to the user and I would like to update the Work Notes with some information once the workflow in ICO is complete.
The way we're accomplishing something of this sort right now is via different table specifically for ICO, the Task ID of which is sent into ICO in order to start the workflow. We can use that Task ID to update its Work Notes, but this Task ID doesn't seem to be visible to the user, and they ultimately end up receiving the update through an email, which we would like to avoid entirely.
So in short, I suppose this could be remedied if it's possible for ServiceNow to know the sys_id for the sc_req_item which will be visible to the user through their Requests dashboard and send it to ICO.
Please let me know if any points of clarity are required.
Thanks,
Matt Bowler
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2015 07:02 AM
Request items know about the request, not the other way around. You would have to make the getRecords call against sc_req_item and return records where the request is the sys_id you have:
var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://dev13851.service-now.com/api/now/table/sc_req_item?sysparm_limit=10&sysparm_query=request=18...
request.setHttpMethod('GET');
//Eg. UserName="admin", Password="admin" for this code sample.
var user = 'admin';
var password = 'admin';
request.setBasicAuth(user,password);
request.setRequestHeader("Accept","application/json");
var response = request.execute();
gs.log(response.getBody());