- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2025 10:24 AM
The below is my onSubmit client script I have written inside the MultiRow Variable set. My problem is after each selection and add I do not want duplicate records that is the user must select unique combination each time here my multirow variable set is has 3 variables all 3 are lis collectors but I tried to write this script but its not working any suggestion how to achieve this or any code changes required ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2025 10:38 AM
Hi @kirankr2061
try this
function onSubmit() {
// Get current row values (multi-select list collectors)
var currentCloud = normalize(g_form.getValue('ten_mrvscloud_account_name'));
var currentRoles = normalize(g_form.getValue('ten_mrvs_roles'));
var currentUsers = normalize(g_form.getValue('ten_mrvs_user'));
// Get previously submitted rows (excluding the current one being added)
var rows = JSON.parse(g_service_catalog.parent.getValue('tenable_add_role'));
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
var existingCloud = normalize(row.ten_mrvscloud_account_name);
var existingRoles = normalize(row.ten_mrvs_roles);
var existingUsers = normalize(row.ten_mrvs_user);
if (
currentCloud === existingCloud &&
currentRoles === existingRoles &&
currentUsers === existingUsers
) {
g_form.addErrorMessage('cloud_account_name', 'This combination of Cloud Account, Roles, and Users already exists. Please enter a unique combination.', 'error');
return false;
}
}
return true;
}
function normalize(sysIdString) {
if (!sysIdString) return '';
var parts = sysIdString.split(',');
parts.sort();
return parts.join(',');
}
,
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2025 10:35 AM - edited ‎06-25-2025 10:59 AM
If you add some alerts you'll see the 'existing' script variables do not contain the data you expect. You'll also want to uncomment the sort method so that your normalize function does something.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2025 10:38 AM
Hi @kirankr2061
try this
function onSubmit() {
// Get current row values (multi-select list collectors)
var currentCloud = normalize(g_form.getValue('ten_mrvscloud_account_name'));
var currentRoles = normalize(g_form.getValue('ten_mrvs_roles'));
var currentUsers = normalize(g_form.getValue('ten_mrvs_user'));
// Get previously submitted rows (excluding the current one being added)
var rows = JSON.parse(g_service_catalog.parent.getValue('tenable_add_role'));
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
var existingCloud = normalize(row.ten_mrvscloud_account_name);
var existingRoles = normalize(row.ten_mrvs_roles);
var existingUsers = normalize(row.ten_mrvs_user);
if (
currentCloud === existingCloud &&
currentRoles === existingRoles &&
currentUsers === existingUsers
) {
g_form.addErrorMessage('cloud_account_name', 'This combination of Cloud Account, Roles, and Users already exists. Please enter a unique combination.', 'error');
return false;
}
}
return true;
}
function normalize(sysIdString) {
if (!sysIdString) return '';
var parts = sysIdString.split(',');
parts.sort();
return parts.join(',');
}
,
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya