Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Issue with Catalog Item using MRVS

Chris33
Tera Contributor

All - 

 

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));
		}
	}
}

 

 

Thank you!

0 REPLIES 0