Prevent duplicate entries being selected in a multi row variable set

matthew_hughes
Kilo Sage

I've got a multi row variable set that allows a user to select different AMA controls. However, what I've just noticed is that a user is able to select the same control twice for a Business Application.

Duplicate AMA controls.png

If the above example, the user should only select the 'Manual Order Process' AMA control only once. I was just wondering what I can do to stop the same AMA control being selected. A user should only select each AMA control once, not multiple times.

18 REPLIES 18

Prince Arora
Tera Sage
Tera Sage

Hello @matthew_hughes 

 

I hope you are doing well!

 

You can write a onSubmit client script on your MVRS, for the reference please follow the link here having same requirement

 

If my answer solved your issue, please mark my answer as  Correct & 👍Helpful based on the Impact.

 

I've tried the following, but it's not worked:

 

function onSubmit() {
var value = parent.g_form.getValue("ama_controls"); // change mrvs name
var arr = JSON.parse(value);

if (searchExisting(g_form.getValue("ama_control"), arr)) {
alert('There are duplicates please remove those before submitting');
return false;
}
}

function searchExisting(keyColumn, newArray) {
for (var i = 0; i < newArray.length; i++) {
if (newArray[i].ama_control == keyColumn) {
return true;
}
}
return false;
}

 

It states 'There is a JavaScript error in your browser console'

@matthew_hughes 

 

Can you check the console what is the error came up

Right click on your form where error has came up and click on inspect

 

PrinceArora_0-1688138385292.png

 

The error I'm getting is:

TypeError: Cannot read properties of undefined (reading 'getValue')