make category field read only based on other field

VSN
Tera Expert

requirement is:

i am using 2 fields, 

  • Employee type (true/false type).
  • Category (choice field. L1-1,L1-2,L1-3,,,  default value is  L1-1.

So, my requirement is if i select the Employee type as True, then category field display the choice as L1-3, and read only.

if i select employee type as false then category field display the choice  is L1-1, and editable. 

 

How to get this functionality ,,, if possible using ACL..

1 ACCEPTED SOLUTION

Write onload client script and onchange  with above script it will work.

 

Thanks,

Anand

View solution in original post

3 REPLIES 3

Anand Kumar P
Giga Patron
Giga Patron

Hi @VSN ,

ACL its not possible only we can achieve this through onchange client script on Employee Type field.

(function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var employeeType = g_form.getValue('employee_type');
  if (employeeType === 'true') {
        g_form.setValue('category', 'L1-3');
      g_form.setReadOnly('category',true);
    } else {
        g_form.setValue('category', 'L1-1');
         g_form.setReadOnly('category',false);
    }
})(control, oldValue, newValue, isLoading, isTemplate);

Please mark it as solution proposed and helpful if this serves your purpose.

Thanks,

Anand

@Anand Kumar P  

it is working for only new record, after saving the form category field is editable even category is L1-3

Write onload client script and onchange  with above script it will work.

 

Thanks,

Anand