- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2022 07:59 PM
Hi,
I am trying to compute the total value of 1 of the column in the MRVS and displayed onto a variable in the record producer as shown below:
I have followed the guide from the below link but to now avail.
From the below catalog client script, I have encountered error due to the parsing of the g_formGetValues. I also found out that the result of console.log(g_form.getValue('billing_request_insert_details')) is returning empty values despite I have filled the relevant field in the MRSV.
Catalog Client Script
MRSV in preview
Error in Console
Details of MRSV
I would appreciate if anyone could assist on my problem.
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2022 09:56 PM
Hi
You can follow my reply to a similar community thread:
Add the total cost in multirow variable set
This thread might give you the required solution. Please check and let me know if you still face the issue.
Please mark my answer as correct if this solves your issues!
If it helped you in any way then please mark helpful!
Thanks and regards,
Kartik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2022 09:01 PM
Hi,
can you share your script here instead of script screenshots?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2022 09:02 PM
Hi
onSubmit of MRVS variable set won't work
Please change the onSubmit to Applies to Catalog Item and then it would work fine
you will get JSON; you will get total etc
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2022 09:13 PM
Hi Ankur,
Please see below script as requested.
I have applied the below script to a variable set (You can refer to screenshot on the catalog client script).
Thanks.
function onSubmit() {
//Type appropriate comment here, and begin script below
var multiRowVariableSet = JSON.parse(g_form.getValue('billing_request_insert_details')); // Replace your variable set Name and not label here.
var totalCost = 0;
for (var i = 0; i < multiRowVariableSet.length; i++) {
totalCost += multiRowVariableSet[i].billing_request_gst_amount_s; //add all totals from the MRVS to 1 total
}
alert(totalCost);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2022 11:15 PM
So what was the outcome?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2022 01:28 AM
I have changed as advised but no alert is triggered. I think I need to create a submit button/variable for the catalog item for the onSubmit to work.
Since the widget approach as guided by Kartik is working, I will stay as it is.
Anyway, thanks for your help Ankur