- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2019 03:07 AM
Hi,
Coming across using the MRVS and wish to calculate the total amount for the number of books as shown in the pic.
Appreciate if anyone can enlighten me. I did do a checkup from this post but can't really get the idea.
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2019 09:48 PM
Hi Si Min,
The Client Script used in a widget is different than an on submit client script for a record / record producer / catalog item. It needs to use $scope to get access to g_form. However client scripts on Catalog Item, Record Producer and Ticket record have access to the GlideForm (g_form) client side API.
Try the following for your onSubmit client script:
function onSubmit() {
var totalEstimatedAmount = parseFloat(g_form.getValue('total_estimated_amount_sgd'));
var jsonStr = g_form.getValue("book_details");
var objList = JSON.parse(jsonStr);
var calculatedAmount = 0;
for (var i = 0; i < objList.length; i++) {
calculatedAmount += parseFloat(objList[i].estimated_price_sgd);
}
calculatedAmount = calculatedAmount.toFixed(2);
if (calculatedAmount != totalEstimatedAmount) {
g_form.addErrorMessage('Total estimated amount does not match with entered Book Details info. Please click the Calculate Total Estimated Price again before submission.');
return false;
}
}
Hope this helps!
Cheers,
Manish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2019 07:26 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2019 09:28 PM
Ah clear.
Like Manish mentioned, "But there is one problem, you can't access the variables outside MRVS from client script of MRVS variable set." At least, until Madrid this is the thing. I haven't yet tested this on New York.
For a similar requirement, we have a sum field, filled upon submission of the request. Actually not thru a onSubmit Catalog Client Script, though thru an Async Business Rule.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2019 10:03 PM
Just tried in New York. Still not possible thru onChange Catalog Client Script.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-11-2021 08:50 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2019 06:35 PM
Hello Si Min,
Please refer to the blog detailed by Mark here
Here he describes the way we can access the details in MRVS
by using g_form.getValue("IO:Sys_id of MRVS");
you will get the details filled in MRVS as an array of JSON objects where you can parse that array element objects and get the values for the particular column , add it and set them back
Hope this helps :
Mark this response as correct if that really helps
Thanks,
Siva