Client script question to show/hide field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2012 07:41 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2012 07:59 AM
Maybe greater than instead of less than here?
wf.indexOf('validate the device')<0)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2012 08:04 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2012 08:00 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2012 08:09 AM
use
g_form.setDisplay('u_equipment_to_be_installed', true);