- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-16-2023 03:06 AM
HI ,
Can someone please help on this
I have MRVS with two variables quantity and month, if i enter the value of quantity records
i want the sum of the quantity values to be displayed in total quantity variable which is outside of the MRVS
need a on change client script as user can change the quantity , so Total quantity should show updated value
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-17-2023 04:28 AM - edited ā11-17-2023 05:06 AM
Hi @harinya
There are a few steps you need to take:
First on your catalog item, create a (hidden) field 'quantity_updated' (type checkbox).
Then Create a onLoad Client script on your catalog item:
function onLoad() {
//We need to make the g_form object for the MRVS available for later
this.cat_g_form = g_form;
}
Second, create a onChange Client script on your catalog item, which triggers on change of quantity_updated. Please note that you need to fill the name of your MRVS.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '' || newValue == 'no') {
return;
}
g_form.setValue('quantity_updated', false);
//Need to set a timeout because MRVS is not readable directly.
setTimeout(function() {
var mrvsRows = g_form.getValue("<<FILL MRVS NAME>>");
var oMrvs = JSON.parse(mrvsRows);
var total_quantity = 0;
for (var i in oMrvs) {
total_quantity += parseInt(oMrvs[i].quantity);
}
g_form.setValue("total_quantity", total_quantity);
}, 500);
}
And last create a onSubmit Client script in your MRVS:
function onSubmit() {
//Service Portal logic
if (this) {
this.cat_g_form.setValue('quantity_updated', true);
} else {
//Native UI logic
parent.g_form.setValue('quantity_updated', true);
}
}
That should be it.
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-20-2023 12:29 AM
Hi @harinya
You can replace
total_quantity += parseInt(oMrvs[i].quantity);
by
total_quantity += parseFloat(oMrvs[i].quantity);
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-19-2023 12:59 AM
HI @Peter Bodelier ,
The hidden variable quantity_updated , i have made it visible and when i clicked on(quantity updated) checkbox the total quantity value is coming up, so here my query is how to display total quantity value without clicking the variable checkbox

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-19-2023 11:43 PM
This should be updated by the onSubmit client script. So something in your config is not correct there.
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-20-2023 12:18 AM
Hi @Peter Bodelier ,
I have one query, if the quantity is a decimal value how to achieve the total quantity with decimal the current code is not considering the decimal values, in below snap the expected value should be 63.4
Can you please help on this

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-20-2023 12:29 AM
Hi @harinya
You can replace
total_quantity += parseInt(oMrvs[i].quantity);
by
total_quantity += parseFloat(oMrvs[i].quantity);
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-17-2023 03:19 AM
You can try the solution posted here: