- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2017 10:04 AM
Hi,
After upgrading from Eureka to Helsinki we've had a lot of issues with users' shopping carts being corrupted, causing the requested for on new service catalog requests to be read only and populated with the previous user they entered a request for. This has been a particular issue for the service desk due to how many tickets they work. It appears that the issue is at least partly due to how our order guides work in Helsinki so in the meantime we've suggested the service desk use the individual catalog items instead, which has partly cut down on the issue but not altogether. When I disabled all properties related to 2 step checkout in our Dev and Test instances the issue went away but that opens us up to people making changes to submissions to the service catalog they shouldn't be making.
The admins have been manually deleting shopping carts for users when they get corrupted but it's too time consuming for us to keep doing. I was thinking of maybe putting a module under Self-Service called "Clear My Shopping Cart" which would run a script that deletes all the records in sc_cart for that particular user. Does anyone know how to do this? I've seen suggestions elsewhere for people who have had this issue to create an onLoad client script which autoclears the shopping cart whenever a user opens a new order guide or catalog item but I feel fairly confident our service desk would have issues with that as well (e.g. if the open up an item, then go look at another item and try and come back to complete their submission). Basically, if anyone knows how to run a client side script from a module or something on the ITIL homepage that would be great.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2017 12:38 PM
The basic idea here seems to work. However because a lot of times there will be additional carts with sys ids for names rather than the DEFAULT name I took off that condition and ran the delete in a loop. Here's what worked for me:
Condition: current.sys_id==gs.getUserID()
Script:
clearUserCart(gs.getUserID());
action.setRedirectURL(current);
function clearUserCart(user) {
var cart = new GlideRecord('sc_cart');
cart.addEncodedQuery('user='+user);
cart.query();
while(cart.next()){
cart.deleteRecord();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2017 08:22 PM
Hi Robert,
You can provide a "Clear My Shopping Cart" form link UI Action on the user profile(sys_user table) and allow the users perform this update.
The below code should work (make sure form link and Show update is marked on UI Action)
Add Condition as current.user_name==gs.getUserName()
and Script as
clearUserCart(gs.getUserID());
action.setRedirectURL(current);
function clearUserCart(user) {
var cart = new GlideRecord('sc_cart');
cart.addEncodedQuery('name=DEFAULT^user='+user);
cart.query();
cart.next();
cart.deleteRecord();
}
Let me know if this worked
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2017 12:38 PM
The basic idea here seems to work. However because a lot of times there will be additional carts with sys ids for names rather than the DEFAULT name I took off that condition and ran the delete in a loop. Here's what worked for me:
Condition: current.sys_id==gs.getUserID()
Script:
clearUserCart(gs.getUserID());
action.setRedirectURL(current);
function clearUserCart(user) {
var cart = new GlideRecord('sc_cart');
cart.addEncodedQuery('user='+user);
cart.query();
while(cart.next()){
cart.deleteRecord();
}
}