Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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

Mark Stanger
Giga Sage

Maybe greater than instead of less than here?

wf.indexOf('validate the device')<0)


Actually -- it was my own fault. The variable name is different in each task, but I failed to realize that until after I posted to the forum. However, I'm running into something else. The field is hidden, but there is a blank area with the field should be. How do I colapse that?


DubeyN
Mega Expert

Hi,

try one of below if Condition :


if((wf.indexOf('validate the device')>0) || (wf.indexOf('Installing hardware') ==0))

or

if((wf.indexOf('Install/validate the device') ==0) || (wf.indexOf('Installing hardware') ==0))


As you said actual workflow activity is "Install/validate the device" and in if condition you mentioned 'validate the device'.

ND


DubeyN
Mega Expert

use

g_form.setDisplay('u_equipment_to_be_installed', true);