- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 11:54 AM
Hello,
I need to update the quantity in a catalog item based on number of records in the reference field of a variable before submission. I think I need to write a onChange catalog client script .Kindly provide assistance in writing the script. Thanks in advance.
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2022 10:01 PM
Okay.
I don't think you can modify the quantity based on the change of Multi Row Variable Set.
Have tried in my PDI when you add a new Row in MVRS , I have not seen any method to get the length of it based in which you can set the quantity of the cat item.
What you can do if you need this to be done with an On Change Script then that On Change Script need to be written on some other variable on the form and then you can achieve this using an On Change Script.
For example, I have a Variable as "Requested For" which I am selecting after adding Rows in MVRS and it will work fine:
Below script can be used:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue) {
var multiRowVariableSet = JSON.parse(g_form.getValue('demo_variable_set')); // Replace "variable_set_1" with your Variable Set Name. Make sure to replace it with Name and not with Label of Multi Row Variable Set
var numberOfRows = multiRowVariableSet.length;
g_cart.setQuantity(numberOfRows);
}
//Type appropriate comment here, and begin script below
}
Make sure the Rows are added to your MVRS and then you are changing the other variable value:
This works for me in my PDI. Let me know if you are facing an issue.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2022 08:10 AM
Hi
I have tried this on a 'Manager' user reference variable, only thing I changed was the mrvs name. When I change the variable value, I'm getting a javascript error message.
Any ideas what might be causing this?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2022 05:46 PM
Thanks a lot Shloke. It worked.