Variables in a variable set

miyu
Tera Guru

I want to get the value of a variable in a variable set in a catalog client script.
How do I set up the catalog client script?

1 ACCEPTED SOLUTION

Rajneesh Pande1
Kilo Expert

Hi Miyu,

Is your variable set a normal variable set or multirow variable set?


For a normal variable set you can retrieve the value as follow:
var a = g_form.getValue('yourvariablename');

For multiRow variable set following is the syntax:
var serv = g_form.getValue('variableSetName');
var servData = JSON.parse(serv);

After parsing the JSON you can reterive the values:

var a = servData[i].yourvariablename;

here i is the index from which you want to reterive data.

Also you can define an array and store data in that array if there is multiple values.
var appSerSysIDList = [];

for (i = 0; i < servData.length; i++)
appSerSysIDList = appSerSysIDList + servData[i].yourvariablename+ '\n';
g_form.setValue('varName_where_you_want _to_store', appSerSysIDList.trim());

Please reach out if you need more clarification regarding multirow variable set.


Hope this helps.
Please mark the answer correct/helpful as applicable.

View solution in original post

8 REPLIES 8

Kunal Varkhede
Tera Guru

Hi,

 

Try with this,

In Catalog Client script:

g_form.getValue('Name OF Variable');

In Server Side Operation

var variable_value = current.variables.variableName;

You can also perform the dot walking in case of reference field.

 

Thanks,

Kunal

vikas shukla
Kilo Guru

HI,

Follow the below link it is really helpful for you:

https://community.servicenow.com/community?id=community_article&sys_id=2a508caedbf47f48d82ffb2439961...

please mark appropriate respons.

If not, please tell me what you are still missing.

Many thanks and kind regards,

Vikas

Ankur Bawiskar
Tera Patron
Tera Patron

@miyu 

it is the same syntax as that of normal variable even if your variable is inside variable set

g_form.getValue('variableName');

Regards
Ankur

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

@miyu 

Hope you are doing good.

Did my reply answer your question?

If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.

If not, please let us know if you need some more assistance.

Thanks!
Ankur

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