Set Parent Request Properties from Cart API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2016 08:45 AM
I'm trying to create a request item from an inbound action. I can do this and set variables on the item without issue. It also creates the parent request, which is desirable as well. I'm trying to set properties (like the short_description, description, etc) on the parent request from the inbound action without success, however.
- Can this be done through the cart api?
- Is there a good "object browser" for the Cart object so I can examine all that it has & does? The wiki article for the Catalog api doesn't show how to achieve this.
Thank you,
Michael S.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2016 10:45 AM
Hi Michael,
If you're using something like the example code shown here: Service Catalog Script API - ServiceNow Wiki, you can update the parent request after placing the order. Example:
var rc = cart.placeOrder(); // <-- rc is the sc_request GlideRecord
rc.short_description = 'my short description'
rc.update();
Since rc is just a GlideRecord, you can update fields as needed.
The 'Cart' object is a Script Include, so you can explore the available methods by searching for 'Cart' in the Script Include table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2016 11:31 AM
Hi Josh,
I am using something like the article you posted. I have tried this and the commented out stuff to get the cart again. Neither is saving to those fields:
var rc = cart.placeOrder();
rc.short_description = "Employee Termination";
rc.update();
// var cartGR = cart.getCart();
// cartGR.short_description = email.subject.toString();
// cartGR.description = email.body_text;
// cartGR.contact_type = 'email';
// cartGR.update();
The request and the request item are created and are linked together. But the request properties are not set. This is in an 'Inbound Action'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2016 04:06 PM
Worked when placing the order then immediately querying for the request again and editing it:
var rc = cart.placeOrder();
//Then query for the request and edit
var parentRequest = new GlideRecord('sc_request');
parentRequest.addQuery('number', rc.number);
parentRequest.query();
if (parentRequest.next()) {
parentRequest.contact_type = 'email';
parentRequest.short_description = "Employee Termination";
parentRequest.description = body;
parentRequest.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 07:51 AM
The above simply doesn't work!
