
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2016 03:03 PM
Hi everyone,
I am trying to use the default "Create Request" UI Action on Incident in order to have an itil User order an item on someone's behalf.
The problem is, it is an extra step for the itil User to set the Caller as the Requested for in the Requested for widget in the Shopping Cart, before doing an Order Now on a Catalog Item.
I found that if I searched sc_cart for user=logged-in User (i.e. the itil User) and name=DEFAULT, and updated the Requested For on that record with the Caller, when I reload the browser window, the Requested For widget will now show the Caller. However, if I don't reload the browser window, the value isn't refreshed and the itil User continues to show in the Requested For widget in the Shopping Cart.
Does anyone know how I can force ServiceNow to reload the DEFAULT sc_cart record for the logged-in User without the User having to reload the browser window?
Thanks in advance!
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 05:41 AM
Hi Taarik
You can just modify the code of the UI Action to set the Requested for = Caller, before going to the service catalog:
//Set Caller as requested for on current users cart
var cart = new GlideRecord('sc_cart');
cart.addQuery('user',gs.getUserID());
cart.addQuery('name','DEFAULT');
cart.query();
if (cart.next()) {
cart.requested_for = current.caller_id;
cart.update();
}
else { //Create new cart
cart.initialize();
cart.requested_for = current.caller_id;
cart.insert();
}
//Update saves incidents before going to the catalog homepage
current.update();
gs.addInfoMessage('You will need to navigate back to incident ' + current.number + ' upon request completion');
var url = "catalog_home.do?sysparm_view=catalog_default&sysparm_processing_hint=setfield:request.parent=";
url += current.sys_id;
action.setRedirectURL(url);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 05:41 AM
Hi Taarik
You can just modify the code of the UI Action to set the Requested for = Caller, before going to the service catalog:
//Set Caller as requested for on current users cart
var cart = new GlideRecord('sc_cart');
cart.addQuery('user',gs.getUserID());
cart.addQuery('name','DEFAULT');
cart.query();
if (cart.next()) {
cart.requested_for = current.caller_id;
cart.update();
}
else { //Create new cart
cart.initialize();
cart.requested_for = current.caller_id;
cart.insert();
}
//Update saves incidents before going to the catalog homepage
current.update();
gs.addInfoMessage('You will need to navigate back to incident ' + current.number + ' upon request completion');
var url = "catalog_home.do?sysparm_view=catalog_default&sysparm_processing_hint=setfield:request.parent=";
url += current.sys_id;
action.setRedirectURL(url);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 05:57 AM
Hi Lars,
Thanks for your code. I have the same code essentially, but have it with a client portion as well for completeness-checking...and my code is buggy. But at least you proved the concept works and I can just debug my stuff.
Thanks for your help!!