How to restrict duplicate values in MultiRow Variable set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 05:10 AM
Hi All,
How to restrict duplicate entries in a multi row variable set. I am not able to fetch values from that.
Kindly help asap.
Any help is appreciable.
Thanks & Regards,
Surya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 07:07 AM
You can run a script like this onChange of some/every variable in the MRVS, or onSubmit within the MRVS should suffice.
var mrvs = g_service_catalog.parent.getValue('mrvs'); //MRVS internal name
if (mrvs.length > 2) {//native UI returns [] for empty MRVS value which causes a parsing error
var obj = JSON.parse(mrvs);
for (var i=0; i<obj.length; i++) {
if (obj[i].variable_name = g_form.getValue('variable_name') {
alert('Duplicate value');
return false;
}
if (obj[i].variable_name2 = g_form.getValue('variable_name2') {
alert('Duplicate value');
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 10:55 PM
Hi, Brad Bowman
thanks for your sharing, it works.
but i have another issue, "return false" does not work, duplicate record still can be added to list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 04:58 AM
Is your script onSubmit and applies to the MRVS not the Catalog Item?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 05:17 PM
thanks for replying,
My script type is onChange and applies to the variable set.
my expected result is when alert message the duplicated record should not be added.