- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 06:45 PM
Hello,
Appreciate your help !
We have added Additional assignee list to incident form.
Now there is a requirement to limit the additional assignee to only 2 users.
One cannot add more than 2 users to the list.
Is that possible, If so could you please guide us on the steps to limit?
-Thanks
Shree
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 07:15 PM - edited 05-29-2024 07:17 PM
Hi @Shree Nag ,
Try this
function onSubmit() {
var assignees = g_form.getValue('YourFieldName').split(',');
if (assignees.length > 2) {
g_form.showFieldMsg('YourFieldName', 'You cannot add more than 2 assignees.', 'error');
return false;
}
return true;
}
If my answer helped you in any way, please mark it as helpful or correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 07:15 PM - edited 05-29-2024 07:17 PM
Hi @Shree Nag ,
Try this
function onSubmit() {
var assignees = g_form.getValue('YourFieldName').split(',');
if (assignees.length > 2) {
g_form.showFieldMsg('YourFieldName', 'You cannot add more than 2 assignees.', 'error');
return false;
}
return true;
}
If my answer helped you in any way, please mark it as helpful or correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 07:48 PM
Hi @Shree Nag
Below posts could be helpful :
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 08:11 PM
you can do this using 2 ways
1) onChange on that field and check the length and show error message on form or field
OR
2) before update/insert BR and show error message
If my response helped please mark it correct and close the thread so that it benefits future readers.
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-03-2024 12:25 PM - edited 06-03-2024 12:54 PM
Hello,
Thank you all for the response.
I added the client script. The error message pops out when I'm adding more than 2 assignees, but I can still add the additional assignee to the bucket and I can update with more than 2 assignees.
What Am 'I missing in this client script, that avoids even adding the additional assignee to the bucket