- 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
‎08-02-2019 08:56 PM
Hi Manish,
Isn't that onSubmit is not apply for MRVS?
I try with this code but when I try to save my catalog item prompted an error mentioning something to do with the onSubmit script.
function onSubmit() {
var reCal = g_form.getValue('total_estimated_amount_sgd');
calculateTotal = function() {
try {
var totalEstimatedPriceSGD = 'total_estimated_amount_sgd';
//Replace mrvs with your variable set name
var jsonStr = $scope.page.g_form.getValue("book_details");
var objList = JSON.parse(jsonStr);
var result = 0;
for (var i = 0; i < objList.length; i++) {
//Replace variable_name with your variable's name
result += parseFloat(objList[i].estimated_price_sgd);
}
If (result!= reCal) {
$scope.page.g_form.addErrorMessage('Total estimated amount is not matches with Book Details info. Please click the Calculate Total Estimated Price again.');
}
} catch (e) {
console.log("Error in the UI Macro Client Script");
}
}
}
Thanks.

- 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
‎08-03-2019 02:45 AM
Hi Manish,
Thanks for your help.
Really appreciate.
Do you come across on how to display the MRVS in the approval screen and hide the add & remove button as well as set the whole MRVS as read-only in catalog task?
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2019 03:42 PM
Hi Si Min,
I am not sure about displaying the MRVS in the approval screen. But you can create a catalog UI Policy on that Catalog Item to make the MRVS read only, and you can check only "Applies to Catalog Task".
Thanks,
Manish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2019 07:04 PM