- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2022 08:03 AM
I am stuck on one requirement. There is one Multi-row variable set in catalog item where requester can add up to 100 users but should not be able to add the same User twice".
How I can restrict this? Please suggest.
Thanks in advance!
Solved! Go to Solution.
- Labels:
-
Request Management
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2022 08:08 AM
Hello ,
For avoiding duplicate entries you can create an on submit client script inside MVRS
PLease use the below script this will work for sure
function onSubmit() {
var value = parent.g_form.getValue("<mrvs name>"); // change mrvs name
var arr = JSON.parse(value);
if (searchExisting(g_form.getValue("<column name to check>"), arr)) { // change column name
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].<column name to check> == keyColumn) { // change column name
return true;
}
}
return false;
}
Please accept the solution if it helped you and close the thread. This might help others too with same query
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2022 08:08 AM
Hello ,
For avoiding duplicate entries you can create an on submit client script inside MVRS
PLease use the below script this will work for sure
function onSubmit() {
var value = parent.g_form.getValue("<mrvs name>"); // change mrvs name
var arr = JSON.parse(value);
if (searchExisting(g_form.getValue("<column name to check>"), arr)) { // change column name
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].<column name to check> == keyColumn) { // change column name
return true;
}
}
return false;
}
Please accept the solution if it helped you and close the thread. This might help others too with same query
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2022 09:25 AM
It worked, Thank you Mohith for quick solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2022 11:53 PM
Hi Mohith,
There is one issue that i found. When i am doing this on catalog form via try it, it is working as expected but when i am selecting the user info via service portal it is not working. We can select same user twice.
Also I am getting "There is a JavaScript error in your browser console" on service portal.
Could you please help on this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2022 11:26 AM
Hello,
usually this happens when there is some thing wrong with the script that we write in catalog client script
Please try these below debugging steps
In your client script check if you selected "Type" as desktop or All.
If you have selected desktop please change it to ALL and try.
please mark this helpful if it solves your issue