
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2025 02:13 PM
I am trying to troubleshoot an issue with a MRVS in a catalog Item. The MRVS contains purchase items ...
Name Type Question Order
mrvs_cost_center Reference Cost Center 100
account_number Reference Account Number 110
quantity Single Line Text Quantity 120
unit_price Single Line Text Unit Price 130
vendor Reference Supplier/Vendor 140
description Multi Line Text Description 150
total Single Line Text Total 160
When a new row is added i need to do a calculation of unit_price * quantity and then store that value in the total variable of the MRVS row. It should be pretty straightforward but I can't update the total value shown on the row. my onChange script works when I change the quantity but I need it work when i add the row, and trying to duplicate the code in an onload script didn't work for me.
function onChange(control, oldValue, newValue, isLoading) { if (isLoading || newValue == '') { return; } var formatter = new Intl.NumberFormat('en-US', {style: 'currency', currency: 'USD', }); if (isNaN(parseInt(newValue))) { g_form.setValue("quantity", ""); g_form.addErrorMessage("Please provide an integer value for Quantity."); } else { g_form.setValue("quantity", parseInt(newValue)); if (g_form.getValue("unit_price") != "") { var mrvs_total = parseInt(g_form.getValue("quantity")) * parseFloat(g_form.getValue("unit_price")); g_form.setValue("total", formatter.format(mrvs_total)); } } }
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 12:51 AM
so basically you want to observe if new row is added or removed.
If yes then check these links which have the solution for it, enhance as per your requirement
MRVS detect when a row is removed or deleted
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
02-06-2025 12:51 AM
so basically you want to observe if new row is added or removed.
If yes then check these links which have the solution for it, enhance as per your requirement
MRVS detect when a row is removed or deleted
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