The CreatorCon Call for Content is officially open! Get started here.

Need help on getting Variable name from MRVS

shaik_irfan
Tera Guru

Hi,

I have a MRVS when i called that i get the variable values in JSON format but i get the backend variable name not Question

 

How to get the question and instead of variable name

 

in the catalog client script if i try using 

alert(g_form.getValue('mrvs_name'));

 

In server side

gs.info(current.variables.mrvs_name); //from workflow 

 

I get the same output in JSON format

 

 

 

Can anyone please help me how to display the questions ?

1 ACCEPTED SOLUTION

If hardcoding is OK, following script will replace the name with the question. Pass strMrvs to script include.

    var columnNames = { // names/question pair of columns in mrvs
        'column1': 'Column 1',
        'column2': 'Column 2'
    };
    var mrvsObj = JSON.parse(g_form.getValue('mrvs'));

    for (var i = 0; i < mrvsObj.length; i++) {
        for (var key in columnNames) {
            mrvsObj[i][columnNames[key]] = mrvsObj[i][key];
            delete mrvsObj[i][key];
        }
    }
    var strMrvs = JSON.stringify(mrvsObj);
    alert(strMrvs);

View solution in original post

13 REPLIES 13

The problem is getting the label name of variables in mrvs from a script on the form.

g_form.getLabelOf() will only get the label of the mrvs and not the labels of variables in mrvs.

I did try it myself, and it gives me the label of the variable. So not sure why you are mentioning otherwise.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn

Mark Roethof
Tera Patron
Tera Patron

Also see this article which I wrote a while back. Is on Variables, though same principle works for MRVS.

https://community.servicenow.com/community?id=community_article&sys_id=9d7cf274db081898190dfb2439961...

I would advise on the variable value, to get the display value

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

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Did this solve your question? Or do we need to follow-up on this?

Please mark this answer as correct if it solves your question. This will help others who are looking for a similar solution. Also marking this answer as correct takes the post of the unsolved list.
Thanks.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn