- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2020 12:14 AM
Hi All,
We want to set the Quantity of catalog item based on a variable in the item.
We wanted to achieve this without using DOM (gel, $, j$, getElementBy, g_form.getControl, g_form.getElement)
Is there any way to achieve the functionality without using DOM
Regards,
JAS
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2020 11:29 PM
Hi All,
Thanks for following up and for your valuable inputs.
I ended up stick with DOM. Yes I could have this validation in workflow and set the quantity in RITM but we are looking for more user friendly way of setting quantity and displaying that to user even before submission. Also we can't have more choices in quantity which is not looking great in classic view/native view of catalog items.
I came across one OOB API which may help others if they are looking to set quantity onchange of any variable in catalog item.
g_cart.setQuantity(10) ==> This API will allow us to set the quantity in UI itself, but the quantity choices should have the value that we are setting. Consider that the quantity choices are 1,2,3,4,5 in this case if we want to set 10 via g_cart.setQuantity(10) it wont work.
Once again thanks for the inputs and time.
Regards,
JAS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2020 05:59 AM
When you use onSubmit & GlideAjax(Async) - The sc_cart_item might be removed when my onSubmit runs for manipulation. in this case also i wont be having that entry in sc_cart_item table.
In this case instead of GlideAjax(Async) try GlideAjax(Sync) that will hold your client script to perform until you get the result from your script include. That might work.
Thanks,
Mohit Kaushik
Mohit Kaushik
ServiceNow MVP (2023-2025)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2020 06:05 AM
Hi,
you cannot use sync GlideAjax in portal
Regard
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2020 06:17 AM
Hi
Then maybe you need to describe a bit more in detail, what you want to achieve with "Setting the quantity of a catalog Item". Maybe I guesses wrong, what you are heading for.
Let me know, please.
BR
Dirk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2020 07:12 AM
Dirk , Mohit, Ankur - As said, I need to set the quantity automatically in shopping cart during submission or at the backend (sc_cart_item) based on a variable in the catalog item without using DOM/Sync GlideAjax.
As said by Ankur - Sync Ajax will not work in Portal, we wanted to have our implementation in both desktop UI and Portal UI.
Are there any ways to do this?
Regards,
JAS

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2020 09:18 PM
Hi
Last try:
OK, if you do have a catalog variable holding the number of items you want to have, I recommend to implement a workflow Run Script on the RITM, which will read this variable and change the "Quantity" of the Requested Item Record (current), to the value of your variable.
This should be a quite easy task to complete this script.
Let me know if that addresses your question and mark my answer correct/helpful, please.
BR
Dirk