client script to restrict user from assigning a task which is not there in assignment group list

Kiran Kumar m
Tera Contributor

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 

1 REPLY 1

Anil Lande
Kilo Patron

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.
}
   
}

 

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande