- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2023 04:01 AM
how to hide already selected dropdown choice in multi row variable set (for next row add - the already selected choice should not display in choices).
I have an mrvs and in that one variable (addtest) of dropdown with some choices test1, test2, test3. If I select test1 in first row add and I want to add next row in the available dropdown choices test2 and test3 should be available.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2023 09:37 AM
Hello Nitin,
Try this below OnLoad script inside your variable set. Make it helpful if its solve your issue.
function onLoad() {
try {
//Type appropriate comment here, and begin script below
var mrvsValues = parent.g_form.getValue('your_mrvs_variable_name');
var obj = JSON.parse(mrvsValues);
for (var i = 0; i < obj.length; i++) {
g_form.removeOption('your_variable, obj[i].your_variable);
}
} catch (err) {
alert("Error:" + err);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2023 05:33 AM
Hi, you can create an onLoad Catalog Client Script for this - remember to change the names in lines 2 and 8:
function onLoad() {
var multiRowValues = g_service_catalog.parent.getValue('technical_name_of_your_mrvs'); // change variable set name here
if (multiRowValues && multiRowValues.length > 2) {
var obj = JSON.parse(multiRowValues);
obj.forEach(function(option) {
g_form.removeOption('your_variable', option.your_variable); // change variable name here
});
}
}
Check out the documentation on g_serverice_catalog here: https://developer.servicenow.com/dev.do#!/reference/api/utah/client/g_service_catalogClientAPI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 11:55 PM - edited 11-08-2023 12:45 AM
Thanks for the script. But an error is coming if we select the edit row option. The values changes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2023 04:15 AM
Hi Arpita,
Can you paste the error message along with example of your usecase here?
Regards,
Appanna.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2023 09:37 AM
Hello Nitin,
Try this below OnLoad script inside your variable set. Make it helpful if its solve your issue.
function onLoad() {
try {
//Type appropriate comment here, and begin script below
var mrvsValues = parent.g_form.getValue('your_mrvs_variable_name');
var obj = JSON.parse(mrvsValues);
for (var i = 0; i < obj.length; i++) {
g_form.removeOption('your_variable, obj[i].your_variable);
}
} catch (err) {
alert("Error:" + err);
}
}