Hide an HTML field with a client Script (Service Catalog )

xif1
Mega Expert

Hello Snow community,

I'm trying to hide an HTML field from the service catalog

I used this method and it works well with every kind of field, expect for the html one,

      g_form.setVisible('my_field_name', false);

Is it a real bug or i missed someting ?

Because it seems to hide the block, but not the content in it.

Screens below :

Supposed to be hide :

Snw1.png

Supposed to show the block

Snw2.png

You can noticed the title item is displayed

Regards,

1 ACCEPTED SOLUTION

manikorada
ServiceNow Employee
ServiceNow Employee

Romain,



Try to use setDisplay() instead of setVisisble


View solution in original post

5 REPLIES 5

manikorada
ServiceNow Employee
ServiceNow Employee

Romain,



Try to use setDisplay() instead of setVisisble


Perfect !



I never used setDisplay() !


So, do you   know, what is the main differences between setVisible() and setDisplay() ?




The wiki just said :


For setDisplay, If the field is hidden, the space is used to display other items. and for setVisible() If the field is hidden, the space is left blank.


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Romain,



As mentioned on wiki, if you use "setVisible()" then the space will be blank for that specific field hidden on the form and the form looks clumsy.


Please let me know if you have any questions.


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Roman,



Best Practice: Use UI Policy rather than this method whenever possible.


GlideForm (g form) - ServiceNow Wiki