- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2019 03:15 AM
Hi Everyone,
I want to set the default value of Company field in MRVS based on Company field outside MRVS. Is this possible?
Thanks,
Diane
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2020 03:07 AM
Have a look at ryanlitwiller reply on https://community.servicenow.com/community?id=community_question&sys_id=5d28d390db272300fb115583ca961920.
this.NOW.[myAttributteName] = g_form.getValue("myfield");
However this doesn't seem to work in the back end but only in the Service Portal from what I can see.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2019 06:23 PM
Hi Diane,
You can set value in MRVS using both client script and server side script (I haven't tried the Server Side bit, but it should work):
Client Side Script:
//Considering there are 2 variables, variable1 and variable2 in your MRVS variable set, and the variable set's internal name is mrvs
var obj = [{"variable1" : "value1", "variable2" : "value2"}, {"variable1" : "value1", "variable2" : "value2"}];
g_form.setValue("mrvs", JSON.stringify(obj));
Server Side Script:
//Considering there are 2 variables, variable1 and variable2 in your MRVS variable set, and the variable set's internal name is mrvs
var obj = [{"variable1" : "value1", "variable2" : "value2"}, {"variable1" : "value1", "variable2" : "value2"}];
current.variables.mrvs = JSON.stringify(obj);
You will have to create the JSON object for the values you want to set, and then stringify the JSON object to be set to the MRVS variable.
Here is another helpful post on the scripting on MRVS:
https://community.servicenow.com/community?id=community_blog&sys_id=865b5aeddbc023c0feb1a851ca9619f9
Hope this helps!
Cheers,
Manish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2019 12:35 AM
Hi Manish,
Thanks for your response. But I am looking for a way to set a field inside MRVS based on another field that is NOT in MRVS. Your code I think is for if both fields are inside MRVS.
Thanks,
Diane

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2019 12:50 AM
If you look at the below excerpts from docs, the functionality is not yet present.
- Scripts that are not included in a multi-row variable set cannot affect variables inside the multi-row variable set. Similarly, the scripts included in the multi-row variable set cannot affect the variables that are not included in the multi-row variable set.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2019 06:58 AM
I still haven't got any luck on this. Any ideas?