Client script for limiting users in Additional assignee list

Shree Nag
Tera Expert

hello All,

Appreciate you response and help.

I have a client script on a incident form to limit the number of users to be added to additional assignee to only 2.

The script written gives the needed error message, when more than 2 users are added, but continues to add the users and lets us submit the incident form.

I need to restrict the user from submitting form and not let the user add more than 2 users.

 

Here is the client script. Please let me know where is it wrong.

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '')
    {
        return;
    }

    var values = g_form.getValue('additional_assignee_list').toString().split(',');
    if (values.length > 2)
    {
    g_form.showFieldMsg('additional_assignee_list', 'You cannot add more than 2 assignees.', 'error');
       
        return false;
    }
    else
    {
        return true;
    }
}

 

1 ACCEPTED SOLUTION

SAI VENKATESH
Tera Sage
Tera Sage

Hi @Shree Nag 

 

You can try the below script and it is working for me in PDI. In place of alert change as per your need.

function onSubmit() {
   //Type appropriate comment here, and begin script below
   var values = g_form.getValue('additional_assignee_list').toString().split(',');
    if (values.length > 2) {
        alert('You cannot add more than 2 assignees.');
        return false;
    }
    else {
        return true;
    }

   
}

Thanks and Regards

Sai Venkatesh

View solution in original post

2 REPLIES 2

SAI VENKATESH
Tera Sage
Tera Sage

Hi @Shree Nag 

 

You can try the below script and it is working for me in PDI. In place of alert change as per your need.

function onSubmit() {
   //Type appropriate comment here, and begin script below
   var values = g_form.getValue('additional_assignee_list').toString().split(',');
    if (values.length > 2) {
        alert('You cannot add more than 2 assignees.');
        return false;
    }
    else {
        return true;
    }

   
}

Thanks and Regards

Sai Venkatesh

Thank you. That worked !