The Zurich release has arrived! Interested in new features and functionalities? Click here for more

How do i hide variables on a catalog item depending on a selection of another variable.

abcmh
Giga Contributor

I have a Service Catalog item that i am working on . I am adding variables to this item which are checkboxes, radio buttons, multivalue drop down selections, text values, date items etc.

If i select a particular check box like "New Contract" , i need to display a couple of date variables and a comments variable.

What is the best way to achieve this ? Any suggestions?

Thanks,

31 REPLIES 31

Write a onChange client script


ncChange of : new Contract


Try this script


script:


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


  if (isLoading ) {


  g_form.setDisplay('<fieldname1>',false);


  g_form.setDisplay('<fieldname2>',false);


  g_form.setDisplay('<fieldname3>',false);


  return;


  }


  if (newValue == 'true'){


  g_form.setDisplay('<fieldname1>',true);


  g_form.setDisplay('<fieldname2>',true);


  g_form.setDisplay('<fieldname3>',true);


  }


  else{


  g_form.setDisplay('<fieldname1>',false);


  g_form.setDisplay('<fieldname2>',false);


  g_form.setDisplay('<fieldname3>',false);


  }


}


Madhu27
Tera Expert

Hi Amol, Please hide all these 3 fields while loading as follows in a separate UI policy.


Contract Start Date         visible = false, Mandatory = leave alone, Read only = leave alone


End Date                                       visible = false, Mandatory = leave alone, Read only = leave alone


Comments                                   visible = false, Mandatory = leave alone, Read only = leave alone


find_real_file.png


If it does not work please send your main catalog item image and your UI policy.



Thanks


reginabautista
Kilo Sage

Hi Amol, try to follow the following set up for the UI policy. This is working perfectly in my personal dev instance.



Note: You need to click on the Advanced view under Related Links to see Onload and Reverse if false.



find_real_file.png


abcmh
Giga Contributor

I tried Madhusudana and Regina's suggestion but still no luck.


Here are the screen shots of the Catalog UI Policy and Actions for the New Contract variable.


find_real_file.png




find_real_file.png


Use my script or regina   suggested. you do not need to write 2 ui policied like onLoad and change.