How to calculate the sum of the value in multi row variable set?

hongsok
Tera Contributor

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.

 

find_real_file.png

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

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

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

27 REPLIES 27

Yes indeed. You can't add a seperate floating variable just for the sum on the MRVS. So a workaround would be to have a Total variable outside your MRVS.

After submitting your Catalog Item, it would show something like:

find_real_file.png

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

vasu17
Tera Contributor

HI @Mark Roethof,
Can you please help me i have also same requirement it's working as you suggested
But here as this is a business rule but i want this same for on change client script because the total cost needs to be compared with other variable
can you please help me on this 

hongsok
Tera Contributor

Hi Mark,

What should replace with the long sys ID?

If you are using only 1 MRVS for this, the sys_id of your Size GB variable which is in your MRVS. Something like:

grMRVSAnswer.addEncodedQuery('parent_id=' + current.getUniqueValue() + '^item_option_new=b9901a2edb68f304ceed9ce8db961934');

Just replace the sys_id.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

hongsok
Tera Contributor

The field that I am going to sum name: "size" and the result name: "total_disk_size"