How to restrict duplicate values in MultiRow Variable set

suryamol_s
Kilo Guru

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

10 REPLIES 10

Brad Bowman
Kilo Patron
Kilo Patron

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;
        }
}

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.

 

Tera Sage

Is your script onSubmit and applies to the MRVS not the Catalog Item?

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.