How to calculate Total in MRVS when users enter values in any order?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2025 03:36 AM
Hi everyone,
I'm working on a Multi-Row Variable Set (MRVS) in a catalog item and need help with calculating a Total field based on the values entered in multiple fee fields.
Use Case
I have the following fields in my MRVS:
transportation_fee
accomodation_fee
meal_fee
other_fee
total (read-only)
Users can enter values in any order in any of the fields above (some fields may even be left blank). Once all the fee fields have values (or at least the fields that are filled), the Total field should automatically update with the sum.
What I Tried
I created a Catalog Client Script of type onChange and set Variable name = None, but it did not get triggered.
I don’t want to create 50 onChange scripts if I have 50 fields.
I want a single script that can listen to changes in all fee fields and calculate the total.
What I Want
A single client script that can watch all specific fields in MRVS.
It should update the Total field automatically when any fee field is changed.
Can someone help me with:
The best approach to achieve this efficiently?
Any sample script or working example?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2025 03:42 AM
you can use onSubmit catalog client script which applies on MRVS and then get all the values and sum and then set (I haven't tested this)
OR
single field cannot watch
you can check this link and see how it's detecting row is added/removed
so whenever row is added, simply sum and try setting the value
Widget that reacts to onChange event of Variable
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2025 08:05 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2025 02:02 AM
Hi @Ankur Bawiskar,
I have tried it with the onSubmit() but it is not working. It is not setting the value to any of the variables in the MRVS. It will be very helpful if you tell me how to write the onSubmit client script in the MRVS itself to set the value to its own variable.
Thanks,
Ankit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2025 02:07 AM
I tried that yesterday and found it doesn't work.
did you check the link I shared which talks about detecting when row is added/removed
Widget that reacts to onChange event of Variable
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader