Prevent duplicate entries being selected in a multi row variable set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2023 07:54 AM - edited ‎06-30-2023 07:55 AM
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2023 08:28 AM
Can you update this
From:
var value = parent.g_form.getValue("ama_controls"); // change mrvs name
TO
var value = g_form.getValue("ama_controls"); // change mrvs name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2023 08:34 AM
The error is still occurring. This is my code:
 
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2023 09:12 AM
I have tried same script in my PDI and it worked really well
I have used this script:
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;
}
Please check your variable names are accurate!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2023 12:17 AM
Hi @Prince Arora Where are you putting that client script? Are you putting it within the 'Catalog Client Script' tab on the catalogue item or the Variable Set? When I click Submit, I'm getting the error message of 'There is a JavaScript error in your browser console'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2023 02:13 AM