How to populate list collector values based on any specific dropdown value selected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2023 12:03 PM
Hey All,
Actually in the form, I have created two fields one is select box (Please select Region) and another is the List Collector field (Role) and that list collector has the all the variables from all the regions(Used List collector because we need to select multiple options).
The Joy here is Role field is a List collector field and the values of all region are stored in the Variable table and fetching them via filter condition and using them in List Collector - Type Specifications section.
Actual Requirement: When we select a region from the select box the Role field should only populate the region related options and hide the other variables.
Eg: Region field consists of "Global", "EMEA", "USA", "JAPAN".
Roles Fields consists of: "Global-Developers", "Global-Administrator", "EMEA-Developers", "EMEA-Administrator", "USA-Developers", "USA-Administrator", "JAPAN-Developers", "JAPAN-Administrator".
So here when the Global region is selected the roles should be displayed as "Global-Developers" and "Global-Administrator".
I have created the Script Include in which fetching the data based on the region selected but unable to populate the fetched data in the list collector field (in the Catalog Client Script)
Script Include:
if (region == "Global")
{
var global1 = new GlideRecord("item_option_new");
global1.addEncodedQuery("u_required_for_list_collector=true^u_list_collector_name=Soft");
global1.query();
while (global1.next())
{
id.push(global1.question_text.toString());
}
return id.join(',');
}
Note: Tried to remove the single single item using Catalog Client Script from the list collector at run time based on the region selected still it didn't perform as expected.
if (g_form.getValue('please_select_region') == 'global')
{
g_form.removeOption("role","emea_developers");
g_form.removeOption("role",'emea_administrators');
}
Any solutions for this or rather another way to accomplish this requirement.
Thanks In Advance!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 05:48 AM
Hello @Ishwar Havagi
Try this for your script include and see if it works for you:
if (region == "Global") {
var roleArray = [];
var global1 = new GlideRecord("item_option_new");
global1.addEncodedQuery("u_required_for_list_collector=true^u_list_collector_name=Soft");
global1.query();
while (global1.next())
{
roleArray.push(global1.getUniqueValue());
}
return roleArray;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 06:41 AM
Hi @Ishwar Havagi ,
Hope you are doing great.
I had done similar requirement in past , try using below script :
function onChangeRegion() {
var regionField = g_form.getControl('region_field_name');
var roleField = g_form.getControl('role_field_name');
var selectedRegion = regionField.value;
// Clear existing options in the Role field
while (roleField.options.length > 0) {
roleField.remove(0);
}
// Populate Role field with region-specific options
var roleOptions = getRoleOptionsByRegion(selectedRegion); // Implement this function to retrieve the options based on the selected region
// Add the new options to the Role field
for (var i = 0; i < roleOptions.length; i++) {
var option = new Option(roleOptions[i], roleOptions[i]);
roleField.add(option);
}
}
Regards,
Riya Verma