Variables visibility on selecting a particular choice of a field

shivatmika_19
Tera Guru

Requirement: When Onboarding Type field is "Offboarding/Termination Request" all the below fields should not be visible, when other choices are selected below fields should be visible.

 

Case 1: When "Onboarding type" field is "Offboarding/Termination Request" below fields are not visible.

Screenshot 2024-12-10 at 10.39.34 AM.png

 

Case 2: When "Onboarding type" field is other than "Offboarding/Termination Request" is selected all the below fields should be visible.

Screenshot 2024-12-10 at 10.42.15 AM.png

 

Solution:

Write a onchange client script on "Onboarding Type" field.

 

function onChange(control, oldValue, newValue, isLoading) {
        if (isLoading || newValue == '') {
             return;
        }
        var fields = g_form.getFieldNames();
        if(newValue == 'Offboarding/Termination Request'){
                 for (var x = 0; x < fields.length; x++) {
                          if(fields[x] != 'onboarding_type' && fields[x] != 'userid' && fields[x] != 'request_date'){
                                   g_form.setMandatory(fields[x],false);
                                   g_form.setDisplay(fields[x], false);
                          }
                  }
        }
else{
          for (x = 0; x < fields.length; x++) {
                if(fields[x] != 'onboarding_type' && fields[x] != 'userid' && fields[x] != 'request_date'){
                           g_form.setMandatory(fields[x],true);
                           g_form.setDisplay(fields[x], true);
                 }
         }
   }
}
2 REPLIES 2

anshul_goyal
Kilo Sage

Hello @shivatmika_19,

You can achieve this requirement using a Catalog UI Policy. Add a condition where, if the 'Onboarding Type' is not 'Offboarding/Termination Request,' the fields will be visible and mandatory.

Please mark my solution as Helpful and Accepted, if it works for you in any way!

Thanks

Hi @anshul_goyal,

In the above requirement, hiding approximately 30 fields is not ideal to achieve using a UI policy and UI policy actions.