How to create a parent REQ with child RITM (w/ executing WF) from a RESTful POST
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2015 12:11 PM
We have begun development for an external website to be able to submit data from one of its web forms into our ServiceNow instance. We have our prototype working to create an Incident:
RESTful POST > import set table > transform map creates Incident record
For Incident, this is fairly straight forward.
However, this is trickier when it comes to creating a Service Request. Realizing that a transform map needs a single target table defined makes me wonder how this best can be achieved. How could a RESTful submission to an import set table best be transferred into a Service Catalog Request (So, it's as if someone just submitted via a service catalog item form & populated all the form variables)?
Thanks in advance for any help!
- Labels:
-
Integrations
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2015 02:10 PM
Brad,
Appreciate the feedback, we've modified our script as follows:
// If call type is SERVICE CATALOG REQUEST...
// establish a cart adding in the Catalog Item chosen in the Ticket's 'Request Item' field
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem(source.request_item);
// set variables
cart.setVariable(item, 'ohiolink_comments', source.ohiolink_comments);
cart.setVariable(item, 'ohiolink_ip_range', source.ohiolink_ip_range);
cart.setVariable(item, 'ohiolink_ip_services', source.ohiolink_ip_services);
cart.setVariable(item, 'ohiolink_ip_range_description', source.ohiolink_ip_range_description);
cart.setVariable(item, 'ohiolink_listserv_action', source.ohiolink_listserv_action);
cart.setVariable(item, 'ohiolink_listserv_list_names', source.ohiolink_listserv_list_names);
cart.setVariable(item, 'ohiolink_listserv_member_emails', source.ohiolink_listserv_member_emails);
cart.setVariable(item, 'ohiolink_ostaff_actions', source.ohiolink_ostaff_actions);
cart.setVariable(item, 'ohiolink_ostaff_username', source.ohiolink_ostaff_username);
cart.setVariable(item, 'watch_list', source.watch_list);
var request = cart.placeOrder();
var ritm_sysID = "";
// get the created child RITM record
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery("request", request.sys_id);
ritm.query();
// update the RITM's fields accordingly
while (ritm.next()) {
ritm.opened_by = current.opened_by;
ritm.watch_list = current.watch_list;
// Update our RITM record and capture its sys_id
ritm_sysID = ritm.update();
}
ignore = true;
We are still getting the same results though. Jeff had actually suggested running the business rule as you suggested, but the purist in me would REALLY like to contain this all within our import table and the transform map.
I do have a question as I am wondering if we are passing in the incorrect data to identify the catalog requests we want to fire off. We have tried submitting both the SYS_ID and the text of the request item and we are passing the data in to the data item cart.additem.
We did some additional digging, wondering if maybe we we submitting the data to the incorrect table, and made the sc_itm_req the target table. Again. No dice, nothing created when using that method.
Sigh,
Doug
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2015 05:43 AM
Brad,
Slept on it last night.. came in this AM.. and thought Doh.. I need that appended u_ in front of my fields.. changed it to...
cart.setVariable(item, 'ohiolink_comments', source.ohiolink_comments);
and viola.. Worked like a charm.
Thanks for the assistance,
Doug

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2015 07:36 PM
This may be really late to the original post. I just shared a restful processor to expose the Catalog API.
Check it out - ServiceCatalog Custom Rest Processor. It may meet your needs.
Feel free to try it out. Here's a link to the share - ServiceCatalog Custom Rest Processor
Below are screenshots using Chrome's DHC Addon
Calling https://instance.service-now.com/service.do with GET
Headers required: Authorization: Basic (your auth token goes here)
Calling https://instance.service-now.com/service.do?sys_id=01205b180a0a0b3000b6efd641d24b75 with GET
This will get all the details of the item your want to request.
Headers required: Authorization: Basic (your auth token goes here)
Calling https://instance.service-now.com/service.do with POST
This will request the items you tell it in the array you pass. There is no checking if the values you pass would pass client side.
Headers required: Authorization: Basic (your auth token goes here)
Try it out. Maybe it'll meet your needs.