show/hide variables on a task form

paradise623
Giga Expert

Hi

I am looking to show variables and hide variables on a task form. I need it to pertain to specific catalog items. So far I have written the following script, but its hiding it on every catalog item, I need it to hide it only on certain items. How do I do this using this script?

For examples show only these variables if the item "boxes" if selected. If another item is selected then don't show the variables for the item "boxes"

function onLoad() {

g_form.setVisible("variables.xxx",false);

g_form.setVisible("variables.xxxx",false);

g_form.setVisible("variables.xxxx",false);

}

Please help!

1 ACCEPTED SOLUTION

sam_hull
Kilo Expert

Hello,


I believe I answered this wrong the first time so I deleted it. On closer reading, I think something like this might be closer to what you are looking for:



function onChange(control, oldValue, newValue, isLoading) {


        if (newValue == 'boxes')


                  {


                      g_form.setDisplay('variablename', false);


                  }


  }




In this case, it's an onChange script with the Catalog Item selected and the variable selected is the one you want to set to 'boxes'. If that variable is a check box, I think you can just use: if (newValue == 'true')



You can also do this without scripting at all if you use the Catalog UI Policies.


I hope this helps!


View solution in original post

2 REPLIES 2

sam_hull
Kilo Expert

Hello,


I believe I answered this wrong the first time so I deleted it. On closer reading, I think something like this might be closer to what you are looking for:



function onChange(control, oldValue, newValue, isLoading) {


        if (newValue == 'boxes')


                  {


                      g_form.setDisplay('variablename', false);


                  }


  }




In this case, it's an onChange script with the Catalog Item selected and the variable selected is the one you want to set to 'boxes'. If that variable is a check box, I think you can just use: if (newValue == 'true')



You can also do this without scripting at all if you use the Catalog UI Policies.


I hope this helps!


Thanks Sandy!



So the Type should be "onChange".. Got it



But I'm confused should it be applied to a catalog item or variable set?   The variable is based on a selection of drop downs. For example: the field is a drop down and the choices are "boxes, locks, or telephone. If I choose boxes from the selection, then certain variables should show on the task form and requested item.



Also I tried using a UI policy but it for some odd reason it shows all the variables for all items event hough the UI policy is telling it not too.



I have a task within the workflow that shows all the variables but then the UI policy tells it to hide certain variables based on the selection.