Client script question to show/hide field

Blair5
Tera Guru

I have a field that needs to be shown on an sc_task form. The field should show based on wf_activity and a value in a catalog variable. The script looks like this:


function onLoad() {
     //Show the equipment to be installed field and make it read only
     var wf = g_form.getDisplayBox('wf_activity').value;
     var existHW = g_form.getValue('variables.existing_hardware_hw');
     
     if((wf.indexOf('validate the device')<0) || (wf.indexOf('Installing hardware') ==0)){
           if(existHW == 'No'){
                 g_form.setVisible('u_equipment_to_be_installed', true);
                 g_form.setReadonly('u_equipment_to_be_installed', true);
           }else{
                 g_form.setVisible('u_equipment_to_be_installed', false);
           }
     }
}


This works if the workflow activity is "Installing hardware", but it doesn't work if the workflow activity is "Install/validate the device". What am I missing? Do I need to have 2 separate conditions instead of one with an 'OR'?

Thanks
6 REPLIES 6

DubeyN
Mega Expert

use

g_form.setDisplay('u_equipment_to_be_installed', true);

instead of

g_form.setVisible('u_equipment_to_be_installed', true);


Thank you.