- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2018 02:21 AM
Hi Guys,
Is there a way to automatically clear the shopping cart after a certain period of time?
Thanks in advance,
Solved! Go to Solution.
- Labels:
-
Service Catalog
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2018 10:24 PM
Thanks Guys,
You pointed me in the right direction.
I was able to resolve this myself by creating a scheduled job with the below script.
expiredCartItem();
function expiredCartItem() {
var cartItem = new GlideRecord('sc_cart_item');
cartItem.addEncodedQuery('sys_created_onRELATIVELE@dayofweek@ago@3'); //delete item from cart if created more than 3 days ago
cartItem.query();
while(cartItem.next()) {
cartItem.deleteRecord();
gs.log(cartItem.cat_item.getDisplayValue() + " expired and removed from users cart: " + cartItem.cart.user.getDisplayValue());
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2018 10:24 PM
Thanks Guys,
You pointed me in the right direction.
I was able to resolve this myself by creating a scheduled job with the below script.
expiredCartItem();
function expiredCartItem() {
var cartItem = new GlideRecord('sc_cart_item');
cartItem.addEncodedQuery('sys_created_onRELATIVELE@dayofweek@ago@3'); //delete item from cart if created more than 3 days ago
cartItem.query();
while(cartItem.next()) {
cartItem.deleteRecord();
gs.log(cartItem.cat_item.getDisplayValue() + " expired and removed from users cart: " + cartItem.cart.user.getDisplayValue());
}
}