- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2025 08:16 PM
Hi All,
I am working on a requirement, trying build a custom action and the Input Action I have a input with the type List.Core_country and then I am trying to use that values in the script but the below script is not extracting the values insted it throwing the error as "Selected Countries[object GlideRecord]". Please help me how to fetch the list values as input to the script
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2025 08:48 PM
since it's list of GlideRecord you can iterate like this and get the name and story in array
This will work fine
(function execute(inputs, outputs) {
var selectedCountries = inputs.to;
var countryArray = [];
// iterate the object
while (selectedCountries.next()) {
countryArray.push(selectedCountries.name.toString());
}
gs.info('Selected Countries' + countryArray.toString());
})(inputs, outputs);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2025 08:19 PM
Hi @Sagar Rd ,
You need to fetch the actual value from the GlideRecord.
For example, if you want the Name or Country Code of the selected country, you have to use selectedCountries.field_name.
try this
(function execute(inputs, outputs) {
var selectedCountries = inputs.to;
// Assuming you want the 'name' field from Core_country table
if (selectedCountries) {
gs.info('Selected Country Name: ' + selectedCountries.name);
gs.info('Selected Country Sys ID: ' + selectedCountries.sys_id);
} else {
gs.info('No country selected.');
}
})(inputs, outputs);
selectedCountries.name → gets the country name.
selectedCountries.sys_id → gets the system ID of the selected record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2025 08:33 PM
Hi @Community Alums
I have used the same script, but no response I have received.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2025 08:48 PM
since it's list of GlideRecord you can iterate like this and get the name and story in array
This will work fine
(function execute(inputs, outputs) {
var selectedCountries = inputs.to;
var countryArray = [];
// iterate the object
while (selectedCountries.next()) {
countryArray.push(selectedCountries.name.toString());
}
gs.info('Selected Countries' + countryArray.toString());
})(inputs, outputs);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2025 05:19 PM