- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2015 01:41 PM
I am very new to service now so it's possible (hopeful?) that the answer to my question is easy. I'm trying to implement the answer described in this post: Create a request from script via soap requests. I've already learned that writing directly to tables doesn't run business rules, so I set up an incoming soap call with a transform mapping to populate the sc_request and sc_req_item tables. But to implement that solution I also need to do an update, and it looks like you can't do updates from a vanilla web service set up with the default transform map settings (I get an error about the sys_id I'm trying to update not being found - which makes sense, since it's already been moved over to the target table and is no longer in my web service's private version of the table).
On the client side, I am doing the following:
1. create a request with fields populated
2. create a request item with only the following fields populated: active = "True", request = sys_id_of_the_request
3. Call to the following scripted web service, which has an input parameter of ritm_sys_id and output parameters of success and updated_task (both of which I've repurposed for debugging at the moment).
// get the catalog item of the workflow we want associated with our RITM
var cat_table = new GlideRecord('sc_cat_item');
cat_table.addQuery('sys_id', "abcdef01234567890abcdef0123456789" );
cat_table.query();
if( cat_table.next() ){
cat = cat_table;
response.updated_task = cat.sys_id;
}
// update the RITM with the catalog item's sys_id
var rec = new GlideRecord('sc_req_item');
rec.addQuery('sys_id', request.ritm_sys_id)
rec.query();
while (rec.next()) {
rec.setWorkflow( true )
rec.setForceUpdate( true )
rec.setUseEngines( true )
rec.cat_item = cat.sys_id
rec.update()
response.success = "yes"
}
// let the client know which cat_item we used to update the RITM
rec = new GlideRecord('sc_req_item');
rec.addQuery('sys_id', request.ritm_sys_id)
rec.query();
response.success = rec.cat_item.getDisplayValue()
When I execute this script, I get back the correct sys_id of the catalog item in the uodated_task output parameters, but the success parameter just contains "org.mozilla.javascript.Undefined@1a79dc5". Also, when we check the request item via the UI, it doesn't have a workflow associated with it. Is there another way I should be setting the cat_item? Or is there something else I'm doing wrong?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2015 02:09 PM
What is your overall goal here? Are you attempting to create a new catalog item based on the SOAP integration or just order an existing item from the catalog? If you are doing the latter, then using the Service Catalog Script API - ServiceNow Wiki should provide you the result.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2015 02:09 PM
What is your overall goal here? Are you attempting to create a new catalog item based on the SOAP integration or just order an existing item from the catalog? If you are doing the latter, then using the Service Catalog Script API - ServiceNow Wiki should provide you the result.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2015 05:28 AM
I don't *think* the cart will do what I want, but maybe? Here's some more background.
I work for a company that doesn't use ServiceNow directly at the moment (although we're building an app, so we have a few dev instances we can test things on). What I'm working on is a custom integration for one of our clients. For this integration we need to be able to open up service requests in their ServiceNow instance. Since it's not our instance and I want them to be able to customize their service requests in the future without us having to change our integration, it's very important to me that their automation on their side handles as much of this process as possible.
The client has created a custom form to open up service requests of the type that we want. When that form is filled out, it triggers a workflow that handles setting up the service request. They use this manually and it works for them. I just want to create a service request that will do the same things that form does.
I will try the cart API today as soon as they're available to help with changing the script in their environment. In case that won't work based on what I've said, though, I'm leaving the question open for now. I'll give an update on my progress as soon as I can. Thank you.