- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2019 08:45 AM
Hi,
I am using the MRVS and need to sum the value of the hard drive's size as shown in the pic.
I would appreciate if anyone can give me a clue.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2019 09:06 AM
Hi there,
You would have to place a "Total size" variable outside the MRVS for this. Unfortunately though, you would want to calculate that field on the moment you are adding a row. Though, from within the MRVS, you can't influence variables outside the MRVS.
You could think of a workaround. For example, on submission of the Catalog Item, the Total Size will be calculated and the Variable filled. If help needed on this, I can have a look. We have a similar workaround in place.
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
09-13-2019 09:06 AM
Hi there,
You would have to place a "Total size" variable outside the MRVS for this. Unfortunately though, you would want to calculate that field on the moment you are adding a row. Though, from within the MRVS, you can't influence variables outside the MRVS.
You could think of a workaround. For example, on submission of the Catalog Item, the Total Size will be calculated and the Variable filled. If help needed on this, I can have a look. We have a similar workaround in place.
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
09-13-2019 09:11 AM
Here's the workaround we set up. It's a async Business Rule.
Script used on the Advanced section:
(function executeRule(current, previous /*null when async*/) {
var grMRVSAnswer = new GlideRecord('sc_multi_row_question_answer');
grMRVSAnswer.addEncodedQuery('parent_id=' + current.getUniqueValue() + '^item_option_new=b9901a2edb68f304ceed9ce8db961934^ORitem_option_new=cec65e62dba8f304ceed9ce8db9619b8^ORitem_option_new=db55d622dba8f304ceed9ce8db961902^ORitem_option_new=e42a918edb74fb00ceed9ce8db961982^ORitem_option_new=f5e2d6aedb68f304ceed9ce8db961915');
grMRVSAnswer._query();
var totalInt = 0;
while(grMRVSAnswer._next()) {
if(grMRVSAnswer.value != '') {
var amountInt = grMRVSAnswer.value.replace(',', '.');
totalInt = parseFloat(totalInt) + parseFloat(amountInt);
}
}
current.variables.total_amount_eur = totalInt.toFixed(2).replace('.', ',');
current.update();
})(current, previous);
Obviously you have to change your script a bit! Change the Encoded Query for example. Also this script was about decimal value, maybe you don't need that.
If help needed, let me know.
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-02-2020 04:19 AM
We can use this way instead of Glide 'sc_multi_row_question_answer' table .
Here is my working script.
(function executeRule(current, previous /*null when async*/ ) {
var mrvs = current.variables.vendor_information; //variable set internal name
var totalRows = mrvs.getRowCount();
var total = 0;
for (var i = 0; i < totalRows; i++) {
total = total + mrvs.getRow(i).getCell('vendor_price').getCellDisplayValue() * mrvs.getRow(i).getCell('quantity').getCellDisplayValue(); //provide value of variable
}
var req = new GlideRecord('sc_request');
req.get(current.request);
req.price = total.toFixed(2);
current.price = total; //set value on request form
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2019 09:42 AM
Hi Mark, do I need to create a variable outside the MRVS for the total?