How to retrieve a variable set variable value from server script in service portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 10:00 PM
Hai Team,
I am trying to access variable set variable value in server script in a widget.I am creating a UI button to repopulate the value of rejected catalog item in a new item and I was able to retrieve the values of all variables in service script of the widget .The sample code goes like this
var gr = new GlideRecord($sp.getParameter('table'));
var recordSysId = $sp.getParameter('sys_id');
data.recordExists = gr.get(recordSysId);
(using variables.variables_name I was able to get the variables values like I mentioned below)
data.varname = gr.variables.variable field_name.toString();
using this I am able to retrieve the variables value from rejected record but unable to get the variable set variable values.It is a multirow variable set.
Any suggestions please

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 10:22 PM
Hi,
Muti row variable set data is stored in JSON format.
Refer the below article to access data from Multi Row Variable Set
https://community.servicenow.com/community?id=community_blog&sys_id=865b5aeddbc023c0feb1a851ca9619f9
Note: You need to use Internal Name used in MRVS which accessing it. Variable access_list refered in this article refers internal name of the Multi Row Variable Set
Let me know if you have any specific requirement
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 10:49 PM
Hi,
data for MRVS is stored in JSON format.
So you need to parse it to get individual variables within MRVS
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2022 12:35 AM
I have been working on scoped application so most of the get methods is not working getting the error "Method returned an object of type which is not allowed in scope".I saw a workaround for the issue with this issue .To call the variable set value like this,
gr.variables_set_name.toString().variable_set_variable_name;
getting the value as undefined not sure how to proceed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2022 09:50 AM
Hi,
you can simply use this syntax to get variable value
var val = gr.variables.variableSetName;
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader