- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 11:00 PM
Hi can anyone help me with the scenario for the catalog item there is a list collector variable which is referencing to access types table, i want to hide a option from the list collector variable for the catalog item only.
option name : Vpn access
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 11:41 PM
is that variable part of some variable set and that variable set is used in multiple catalog items?
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-25-2023 11:13 PM
Hi @raj765_32 ,
Hope you are doing great.
- Open the catalog item for which you want to make modification in variables.
Identify the list collector variable that references the access types table. (make a Note of variable's name or sys_id
Create a new client script for the catalog item from related list "catalog client script" from catalog item formadd the following code snippet:
function onLoad() { var variableName = 'your_variable_name'; // Replace 'your_variable_name' with the actual variable name or sys_id // Get the reference to the variable var variable = g_form.getControl(variableName); // Check if the variable exists if (variable) { // Get the dropdown element within the variable var dropdown = variable.selectBox; // Iterate through each option in the dropdown for (var i = 0; i < dropdown.options.length; i++) { var option = dropdown.options[i]; // Check if the option is the one you want to hide if (option.text === 'Vpn access') { // Hide the option dropdown.remove(i); break; } } } }
- Save the client script.
Please make sure to replace 'your_variable_name' with the actual name or sys_id of the variable referencing the access types table in your catalog item.
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 11:24 PM
hi riya
below the code i have written
its not working
function onLoad() {
var variableName = 'what_access_do_you_need';
var variable = g_form.getControl(variableName);
if (variable) {
var dropdown = variable.selectBox;
for (var i = 0; i < dropdown.options.length; i++) {
var option = dropdown.options[i];
if (option.text === 'VPN Access') {
dropdown.remove(i);
break;
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 11:41 PM
is that variable part of some variable set and that variable set is used in multiple catalog items?
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-25-2023 11:44 PM
hi ankur no its not a varibale set its just a variable