Accessing Multi-Row Variable Set value outside the... - ServiceNow Community
Mark Roethof
Tera Patron
Tera Patron

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

 

Hi there,

 

A short article to share knowledge gained about accessing values within Multi-Row Variable Setsoutside the actual Multi-Row Variable Set + Client Side! I noticed multiple Community articles with questions about accessing the values outside the Multi-Row Variable Set, though no happy responses yet. Because we were dealing with something similar, and I found a way today... here to share with you!

 

Reading multiple topics, looking Goran's great video's, reading Brad's really strong article, still no clue. Though, today somehow... Eureka!Some of you might have noticed, you can access Variables by IO:ec2c131a0f70b380861309bce1050e1b (some sys_id). Hmmm would that be possible for Variable Sets also? Or in this case Multi-Row Variable Sets? Here it goes...

1) onChange Catalog Client Script, really limited, just for testing purposes

 

1.png

 

(the sys_id is the sys_id of your Multi-Row Variable Set)

2) The result, the value is available!

 

2.png

 

Obviously, you do have to parse to JSON. This test is also very limited, just a small onChange Catalog Client Script. Though it's a start, a start that could give great possibilities!

---

 

And that's it actually. Hope you like it. If any questions or remarks, let me know!

 

C

If this content helped you, I would appreciate it if you hit bookmark or mark it as helpful.

 

Interested in more Articles, Blogs, Videos, Podcasts, Share projects I shared/participated in?
- Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

 

Kind regards,


Mark Roethof

ServiceNow Technical Consultant @ Paphos Group
---

LinkedIn

Comments
Rahul Kathuria
Tera Expert

Mark, This is great.

Is there a way we can restrict the number of rows in multi variable set depending upon a selection made by a user.

We have select box with choice values from 1 to 5. When user selects 2, multi row VS should have only 2 rows, (add button must be disabled after that).

Thanks.

jxsaxton421
Tera Guru

Did someone else get this working? I am having trouble in New York.

 

Does the catalog script have to apply to the content item or the variable set?

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Just verified, still works.

Can you share details about your issue? What you've setup, where your stuck?

Kind regards,
Mark

---

LinkedIn
Community article list

zulu
Tera Contributor

Is there some way to run a client script onChange of a MR variable set variable? I do not see any ability to do this client side.

Harsh Vardhan
Giga Patron
Giga Patron

Adding my answer here.

 

you don't need to pass the sys_id of the variable set , simply access the MRVS variable set by that "Internal Name".

 

 

var gr = JSON.parse(g_form.getValue('Internal Name of Variable set'));

 It will work. 

Achu1
Mega Expert

Hello Mark,

 

Thanks for posting this. I have somewhat similar requirement. We want to set the value of one of the field in Mrvs set to a 'Default value' based on the catalog item main variable. I am not able to pull the catalog variable name into Mrvs. Please help me to resolve this.

https://community.servicenow.com/community?id=community_question&sys_id=60a3680cdb3ebf4023f4a345ca96...

 

 

Thanks,

Achu

siva_
Giga Guru

You can refer this solution which might partially help.

 

https://community.servicenow.com/community?id=community_question&sys_id=def61f32dbf5dc102e8c2183ca961951

 

 

deepak45
Kilo Guru

Hi Mark,

I am not seeing the internal name of the variable set in place of variable name. it's coming blank. 

Kruthika BM
Tera Contributor

@Harsh Vardhan 

var gr = JSON.parse(g_form.getValue('Internal Name of Variable set'));

Can you please help me to understand how to proceed after defining the variable "gr" . I'm trying to do this with the OnChange client script.

 

Regards,

Kruthika

Ghulam Gose Ala
Tera Contributor
Steps to perform after getting the MRVs variable values and parsing it
 
var all_variable = '';
    var mrvsData = g_form.getValue("test_set"); //replace with mrvs internal name
    var mrvsDatastr = JSON.parse(mrvsData);
    for (var i = 0; i < mrvsDatastr.length; i++) {
        all_variable = mrvsDatastr[i].first_variable_name + "  " + mrvsDatastr[i].second_variable_name; //map your variable names from the MRVs
    }
    alert(all_variable); //Will show all the variable values from MRVs 
Version history
Last update:
2 weeks ago
Updated by:
Contributors