How to hide a mandatory field on Service Portal?

Smith Johnson
Tera Guru

Hello,

I have the following record producer on Service Portal.

find_real_file.png

On backend, it looks like this:

find_real_file.png

I want to make the destination field (variable's name --> destination) invisible once the form is loaded on Service Portal.

Thus, I created the following onLoad Catalog client script, while I included a console.log statement in order to see if the script is actually running when the form is loaded.

find_real_file.png

However, when I enter on the record producer on Service Portal, I can still see the destination field (it supposed to be invisible with the catalog client script). As you can see the console.log statement works properly, but the g_form.setVisible() statement is not working.

find_real_file.png

Bare in mind that I want the destination field to be a mandatory field. 

This mandatory field will be visible after, only if for example the user selects "Category A" from another choice field.

What's going wrong here? Any ideas are welcomed.

Thank you all in advance.

Regards,

Smith.

1 ACCEPTED SOLUTION

Willem
Giga Sage
Giga Sage

You can not hide the field as long as it is mandatory.

You can set mandatory to false and then hide it:

g_form.setMandatory('destination', false)

g_form.setVisible('destination', false)

View solution in original post

2 REPLIES 2

Willem
Giga Sage
Giga Sage

You can not hide the field as long as it is mandatory.

You can set mandatory to false and then hide it:

g_form.setMandatory('destination', false)

g_form.setVisible('destination', false)

asifnoor
Kilo Patron

Hi

Few things to check

1. UI type set to All

2. You cannot hide the mandatory field without making it non-mandatory first

g_form.setMandatory("destination",false);

g_form.setDisplay("destination",false);

Mark the comment as a correct answer and also helpful once worked.