client script to restrict user from assigning a task which is not there in assignment group list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 03:43 AM
Hi i have requirement where i need to restrict a user from assigning a task to different asssignment group other than the listed assignment groups . i need to write a client script .
As i'm new to service now i want to write a script for that .
I have some listed assignment groups which will be available to user while he is submitting the task .But if a user is selecting assignment groups other than the listed groups i want to generate an error message asking him to select correct assignment group while he is trying to assign it to other grou[ps

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 04:31 AM
Hi,
Follow below steps:
1. Create onChange Client script that should run onChange of Assignment Group Field.
2. You can use an array in your script to store assignment groups sys_id that are allowed.
3. Check if selected group is from the given list else show error.
Your script would be like this:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var allowedGroups = ["sys_id1","sys_id2","sys_id3"];
if(allowedGroups.indexOf(newValue)<0){
alert('Selected Gorup is not aloowed, please select another group.');
g_form.clearValue('group_field_name'); //here replace name of your field.
}
}
Thanks
Anil Lande