Add items to cart through script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2017 11:26 AM
I am trying to have a script add additional items to a cart when a user clicks "proceed to checkout" automatically. I have tried to write a client script, but get the alert the glide system cant be used. Any ideas how I could add a catalog item to a cart automatically through a script when someone proceeds to a checkout?
This is what I currently have which is not working:
function onSubmit() {
var existingCart = new GlideRecord('sc_cart');
existingCart.addQuery('user', gs.getUserID());
existingCart.query();
if(existingCart.next()){
var cart = new Cart(); // using "new Cart()" object without parameters
cart.getCart(existingCart.sys_id); // here is where you grab the existing cart. this is not the "getCart()" function from the wiki
var item = cart.addItem('e212a942c0a80165008313c59764eea1');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2017 11:35 AM
Hi Josh,
We can not use server side API directly in client script,
in order to do that, we need to write down client callable script include
http://wiki.servicenow.com/index.php?title=GlideAjax#Overview
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2017 11:40 AM
Deepak - is there an easier way of achieving what I am trying to do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2017 11:56 AM
pradeepksharma any ideas?