- 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 11:18 AM
Hmmm looking at the query closer:
grMRVSAnswer.addSizeQuery
It says addSizeQuery? This should be either addQuery or addEncodedQuery. In this case, addEncodedQuery.
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 11:26 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2019 11:27 AM
One moment, I'm simulating now on my PDI 🙂
Did saw already that the:
+ parseFloat(amountInt);
Is not oke anymore, because amountInt is commented.
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 11:34 AM
Just tried below code, works instantly. Obviously check the sys_id and field names used.
I had to modify slightly because my example code was about multiple MRVS + value with decimals.
(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=bc6fb0f2dbbb7f40b9f39026db9619af');
grMRVSAnswer._query();
var totalInt = 0;
while(grMRVSAnswer._next()) {
if(grMRVSAnswer.value != '') {
totalInt = parseInt(totalInt) + parseInt(grMRVSAnswer.value);
}
}
current.variables.total_disk_size = totalInt;
current.update();
})(current, previous);
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-16-2019 04:19 AM