- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2021 10:12 PM
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2021 10:57 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2021 10:20 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2021 10:20 PM
HI,
Follow the below link it is really helpful for you:
please mark appropriate respons.
If not, please tell me what you are still missing.
Many thanks and kind regards,
Vikas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2021 10:39 PM
it is the same syntax as that of normal variable even if your variable is inside variable set
g_form.getValue('variableName');
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
‎05-30-2021 12:12 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader