How to retrieve a variable set variable value from server script in service portal

BABU15
Tera Contributor

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

7 REPLIES 7

palanikumar
Giga Sage

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  

Thank you,
Palani

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

data for MRVS is stored in JSON format.

So you need to parse it to get individual variables within MRVS

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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.

 

Hi,

you can simply use this syntax to get variable value

var val = gr.variables.variableSetName;

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader