Hide a field when a certain option is not chosen in choice list

Thereza Van der
Tera Contributor

Hi all

 

I have a catalog item (IT Feedback) which has a compliments and complaints drop down. When 'none' or 'compliment' is selected, the dropdown with choices for complaints should be hidden. I cannot get it to work. I attach all necessary screenshots and code.

 

 

Please assist me.

 


Regards

Thereza

1 ACCEPTED SOLUTION

Moin Kazi
Kilo Sage
Kilo Sage

Hi @Thereza Van der ,

 

 

In your UI policy, You have already mention condition now then you can create a UI policy action in the related list where you have to select the field "Nature of Complaint" and set "Visible" field as false and mandatory set to false.

 

Hope this help you.

 

Regards

Moin

View solution in original post

4 REPLIES 4

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

The last bit of code looks like a business rule.

That wont work. 

 

It should be a simple Catalog ui policy that will have the condition -> When 'none' or 'compliment' is selected

and in the ui policy action you can add the field to show

Something like below

AnuragTripathi_0-1729605597686.png

 

-Anurag

sejal1107
Tera Guru
Tera Guru

hi @Thereza Van der 

 

I can see that nature_of_complaint field is mandatory on the form

 

So before making it set display false you should make it mandatory false otherwise it wont be hidden

Please write on change client script on field please_select

 

 

// Get the value of the 'please_select' field
var category = g_form.getValue('please_select');
// Check if the value is 'compliment' or 'none'
if (category == 'compliment' || category == 'none') {
// Hide the 'nature_of_complaint' field
g_form.setMandatory('nature_of_complaint', false);
g_form.setDisplay('nature_of_complaint', false);
} else {
// Show the 'nature_of_complaint' field
g_form.setDisplay('nature_of_complaint', true);
g_form.setMandatory('nature_of_complaint',true);
}

 

 

 

If my response helps you resolve your issue. Kindly mark it as helpful & correct. It will be helpful to future readers

Thanks,

Sejal

Please check and Mark Helpful and Correct if it really helped you.
Thanks & Regards
Sejal Chavan

Moin Kazi
Kilo Sage
Kilo Sage

Hi @Thereza Van der ,

 

 

In your UI policy, You have already mention condition now then you can create a UI policy action in the related list where you have to select the field "Nature of Complaint" and set "Visible" field as false and mandatory set to false.

 

Hope this help you.

 

Regards

Moin

Thereza Van der
Tera Contributor

Thanks for assisting everyone 🙂