OnLoad and OnChange catalog client scripts not working

tcorniels
Tera Contributor

I am trying to create a smart form and am having problems getting the onLoad and onChange catalog client scripts to work correctly.  The form is for users to request access to various business systems.  On the form I have several variables setup as check boxes.  There is additional information needed based on the systems selected, but I want those questions suppressed when the form loads and if the user does not select a particular item.  By default the check boxes are unchecked, but when the user checks one of the boxes I want the additional information questions to appear.  

I have defined the additional information items as regular variables on the form (not in a variable set).  I created an onLoad client script to hide these fields and make them non-mandatory.  I created an onChange script to make the fields visible when the check box value is 'true' (checked).  The problems I am having are:

1. The additional information variables are appearing on the form regardless of the onLoad script, however, IT IS setting the field to non-mandatory.  In the example below (the ServiceNow option) the variable is defined as mandatory by default.

2. When I check the box for the Systems item the onChange script is not making the field mandatory.

3. I have tried both setDisplay and setVisible and neither has worked.

I'm guessing this is something very simple that I am missing?

find_real_file.png

find_real_file.png

find_real_file.png

2 REPLIES 2

Jon Barnes
Kilo Sage

You may want to consider using catalog UI Policies instead, but couple of things from your script:

1. there is an issue with your onchange script. it should be (check where you are closing your paren):

if (g_form.getValue('ServiceNow') == 'true') {

Also, is the field name actually "ServiceNow" or is that the Question label? you will need to make sure you use the actual variable name (case-sensitive)

2. when you are using setVisible and setMandatory functions, use the real boolean true/false, not string 'true'/'false' in the second parameter.

brunda3
Kilo Contributor

Hi,

You can try using UI Policies. I guess it may work.

1. Create UI policy on your catalog item.

2. Select the Catalog Conditions like this as they are checkboxes: "Email or Shared mailbox is True" (OR) "Shared drive is True" (OR)  "service Now  is  True".      

3. Catalog UI Policy Actions like : "Additional Information field make visible True and Mandatory True.

Hit like, Helpful or Correct depending on the impact of the response

Thanks,