- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2021 09:06 AM
We've setup some new Catalog Items that use the flow designer. When I tested creating one of our new Catalog Items from an incident the parent field on the request is not filled in with the incident number. However when I test this with a Catalog Item that uses the workflow it works as expected. The only difference I see is the use of the Flow Designer over the Workflow.
I also verified in our instance to make sure the Request Parent Mapping is populated for incident.
Any thoughts on how we could fix this?
Thanks in advance!
Dom
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2021 09:09 AM
It turned out after much more digging the option "Use Cart Layout" under "Cart Settings" for the catalog item needs to be set to true. If it is set to false this will stop the catalog item from having its parent field filled in when it from an incident.
https://docs.servicenow.com/bundle/quebec-it-service-management/page/product/incident-management/task/create-request-from-incident.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2021 08:39 AM
After a couple hours of digging around, I also came across the "Use Cart Layout" checkbox as the culprit. It also seems, per the link in NFGDom's post, that ServiceNow is aware of this limitation. Many of our Catalog Items do not use the Cart as it's not desired. If you are looking to add this functionality and don't mind minimal customizing, here's what we did to get it working for Catalog Items without the cart:
CatalogTransactionCheckout Script Include:
Without the cart layout, "this.request" comes in without any parameters, so we need to populate them. Using the GlideTransaction.get().getRequest() call, we can pull up the referring URL and parse out the values ourselves.
Here it is so you can easily copy and paste it:
_checkout: function(catalog, catalogView, cartName) {
try {
var view = this.request.getParameter("sysparm_view");
if (!view)
view = "ess";
var referrer = GlideTransaction.get().getRequest().getHeader("referer").toString();
var refItemID, refParentID, refParentTable;
if(referrer) {
refItemID = referrer.substring(referrer.indexOf('sysparm_id=') + 11, referrer.indexOf('sysparm_id=') + 43);
refParentID = referrer.substring(referrer.indexOf('sysparm_parent_sys_id=') + 22, referrer.indexOf('sysparm_parent_sys_id=') + 54);
refParentTable = referrer.substring(referrer.indexOf('sysparm_parent_table=') + 21);
if(refParentTable.indexOf('&') > -1)
refParentTable = refParentTable.substring(0, refParentTable.indexOf('&'));
}
var parentID = this.request.getParameter("sysparm_parent_sys_id") || refParentID;
var parentTable = this.request.getParameter("sysparm_parent_table") || refParentTable;
var params = {};
params.sysparm_parent_sys_id = parentID;
params.sysparm_parent_table = parentTable;
var req = new GlideappRequestNew();
req.setParentParams(params);
var requestRecord;
var cart;
if (!JSUtil.nil(cartName)) {
requestRecord = req.copyCart(cartName);
cart = GlideappCart.get(cartName);
} else {
requestRecord = req.copyCart();
cart = GlideappCart.get();
}
var isNewOrderNow = gs.getProperty("glide.sc.enable_order_now", "false");
if (isNewOrderNow == 'true' && !JSUtil.nil(cartName) && cartName.startsWith('cart_')) {
var def_cart;
def_cart = GlideappCart.get();
// reset requested_for and special instructions property for default cart
def_cart.setRequestedFor(gs.getUserID());
def_cart.setSpecialInstructions('');
//for new order now, an entry was inserted in default cart, on successful checkout, that entry needs to be deleted
var id = gs.getSession().getProperty("default_cart_item");
if (!JSUtil.nil(id)) {
def_cart.remove(id);
gs.getSession().clearProperty("default_cart_item");
}
}
cart.empty();
return this._checkoutRedirect(view, catalog, catalogView, requestRecord);
} catch(e) {
var catalogExceptionUtils = new CatalogExceptionUtils();
if(catalogExceptionUtils.isCartException(e)) {
return catalogExceptionUtils.handleCartException(e);
}
gs.debug(e);
}
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2024 06:47 AM
Hi Team,
Is there any other way to achieve this without modifying the OOB script include: CatalogTransactionCheckout.
Thanks and Regards,
Chandrashekar BN