- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2020 11:24 PM
Hi All,
I have a requirement where I am using a variable as a list collector in a catalog item, where users can select up to 3 choices if they exceed the limit then they should populate the message that the limit is exceeded. please let me know how to achieve this.
Thanks in advance,
Akhil.
Solved! Go to Solution.
- Labels:
-
Customer Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2020 11:35 PM
Hi,
write onSubmit catalog client script
Applies to Catalog Item
Applies on Catalog Item view - True
UI Type = ALL
Note: give your list collector variable name below
function onSubmit()
var values = g_form.getValue('variableName').toString().split(',');
if(values.length > 3){
alert('Please select only 3 choices');
return false;
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2025 10:41 PM - edited 06-17-2025 11:14 PM
Hi @Narra Ramakotes ,
Below the code for Removing the last record .
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var values = g_form.getValue('who_are_need_to_access').split(',');
//g_form.addInfoMessage('total value in users ' + values);
if(values.length > 5){
g_form.clearMessage();
values.pop() // remove the last record
g_form.setValue("DL_Members", Members.join());
g_form.addErrorMessage('Please select only 5 choices');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2021 09:29 AM
I get an unexpected token var error