Need a script to validate the current catalog item is already in the cart list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2015 08:20 AM
I have selected a catalog item and clicked on "Add to cart" twice. catalog item was added twice to the request.In order to avoid this i need to validate on click on "add to cart item" this should throw a pop-up like "Catalog item is already selected do you want to continue?"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2016 07:12 AM
You can just add an onSubmit client script to your Catalog Item - so it would be a Catalog Client Script. It could even be part of a variable set, for that matter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2016 07:13 AM
Just make sure to call the checkCart function from within your onSubmit function - or just paste the contents of the checkCart function into your CS.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2016 07:29 AM
This worked as I would like when Add to Cart is clicked but when Order Now is clicked, it adds the item on the screen to the cart and orders it. I need to have it prompt for Order Now as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2016 07:33 AM
Can you paste your client-side code? You need to make sure you return false if you don't want the form to submit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2016 07:38 AM
function onSubmit() {
checkCart() ;
function checkCart() {
//alert('inside function');
var catItem = gel("sysparm_id").value;
var cart = new GlideAjax('CheckCart');
cart.addParam('sysparm_name', 'checkCart');
cart.addParam('sysparm_catItem', catItem);
cart.getXMLWait();
var resp = cart.getAnswer();
if (resp) {
// prompt user with confirm()
}
// Otherwise, allow submission.
return true;
}
}