Limit Quantity for a Specific Catalog Item

Daniel Arnold
Tera Guru

I currently have the Quantity Field set to 25 available choices. I'd like to limit this to 10 for a specific catalog item. Is there a way to limit this on a per catalog item basis?

 

DanielArnold_0-1754326379741.png

 

3 REPLIES 3

SD_Chandan
Kilo Sage

Hi @Daniel Arnold ,

Refer Documentation :- https://www.servicenow.com/docs/bundle/yokohama-servicenow-platform/page/product/service-catalog-man...

Or

Try this below code which is used to restrict user from selecting more than 5 as quantity and tweak accordingly.?

Code:

Try adding a client script and script include

Client Script:Cart Limit
Applies to Catalog Item
Type: OnSubmit
Applies on Catalog Item View: true

function onSubmit() {
if (cartLimit(g_user.userID) == false) {
alert("Only 5 items allowed in cart");
}
}

Script Include: CartLimit
Client Callable: true
Script:
function cartLimit(userID){
    var cart = new GlideRecord('sc_cart');
    cart.addQuery('user',userID);
    cart.query();
    if (cart.next()) {
        var cartItem = new GlideRecord('sc_cart_item');
        cartItem.addQuery('cart',cart.sys_id);
        cartItem.query();
        if (cartItem.getRowCount() == 5) {
            return false;
        }
    }
}
 
Mark my answer as correct or hit like based on impact.
Please hit like and mark my response as correct if that helps


Thank you
Chandan

SumanthDosapati
Mega Sage
Mega Sage

@Daniel Arnold 

The script in this link might help you.

 

Accept the solution and mark as helpful if it does, to benefit future readers.
Regards,
Sumanth

 

kaushal_snow
Mega Sage

Hi @Daniel Arnold ,

 

For that specific catalog item, enable Hide Quantity = true and Use cart layout = false to remove the default Quantity selector, add a Choice variable limited to values 1‑10 for your users, and then map that variable’s value into the RITM’s quantity field through a Business Rule or Flow Designer, ensuring only up to ten units can ever be ordered for that item, without affecting the global quantity settings....

 

Try this once and let me know..

 

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/