Issue with Hiding Variables in Variable Set on Service Portal: Blank Space Left on Form

Adil a
Tera Expert

Hello ServiceNow Community,

I’m facing an issue with hiding variables on the Service Portal form and need some expert guidance to resolve it. Here's the scenario:

 

  • I have created a variable set that is being used in multiple catalog items.
  • Some variables in this set are not required for certain catalog items.
  • To address this, I created Catalog UI Policies to hide the unwanted variables based on conditions.
  • The variables are successfully hidden on the Service Portal form.

Problem:

After hiding the unwanted variables, the space where the variable was located remains blank. This creates a visual issue on the form, as the blank space disrupts the layout. Ideally, the form should dynamically collapse the space, and the next variable in order should move up to fill the gap.

 

2 REPLIES 2

jcmings
Mega Sage

I have run into a similar issue before. You may have to script the hiding of the variable rather than using the UI Policy Actions. You'll want to use the script g_form.setDisplay('field_name', 'false'). The setDisplay() function reclaims the space when a variable is hidden. 

Anand Kumar P
Giga Patron
Giga Patron

Hi @Adil a ,

 

If you are using setVisible() method it will remain space used to hide the fields on the form. However setDisplay() will reclaim the space if the field is hidden.So use setDisplay method instead setVisible().

 

g_form.setDisplay('short_description', false); This will hide the 'short_description' field and its label on the form.

 

If my response helped, please mark it as the accepted solution and give a thumbs up👍.
Thanks,
Anand