- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2024 02:28 AM - edited 11-07-2024 02:29 AM
Hi All,
My Requirement
Add Group Members , this field should allow only if they added more than 20 members in the list (This will allow only to select more than 20 members to be added in group)
Add Group Members field need to be added (This will allow only to select more than 20 members to be added in group)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2024 05:55 AM
Hi @Saib1 Please try below.
function onSubmit() {
var groupMembers = g_form.getValue('add_group_members');
if (groupMembers) {
var memberCount = groupMembers.split(',').length;
if (memberCount < 20) { /
alert('You must select at least 20 members to add to the group.');
return false;
}
} else {
alert('No group members selected. You must select at least 20 members to proceed.');
return false;
}
return true;
}
Please mark my answer correct and helpful if this works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2024 02:41 AM
Hi @Saib1 ,
You can write onsubmit client script and use below logic to prevent the form submission.
var str = g_form.getValue('add_group_members');
if(str.split(',').length <20)
return false;
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2024 04:11 AM
I need it onChange
Onsubmit will not work because i am doing this in below
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2024 04:23 AM
Hi @Saib1 ,
How you can, you have to select user 1 by 1 and if you run script on onchange the it will be less than 20 user at a time. What is your business requirement.
Also you can use same script in onchange also just remove the return line and display message or clear field value.
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2024 05:01 AM - edited 11-07-2024 05:28 AM
I tried the below script it was giving me the length as '1' if i did not select any value on the list collector