difference between setVisible() and setDisplay() on g_form?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2015 03:43 AM
Hi,
i just read the information about these two methods, both methods cannot hide mandatory fields with no value and the only difference i found is,
setDisplay()
If the field is hidden, the space is used to display other items. that means below field like, if sub status of the incident is not displaying then assignment group will display on that blank space.
setVisible()
If the field is hidden, the space is left blank.you can see the change on the form clearly.
But it is not suggestible to use these methods, instead of this just go for UI policies.
Regards,
Swamy.
- 47,290 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2015 04:57 AM
Hi Kotaiah,
Both methods are used to hide the fields on the form. However setDisplay() will reclaim the space if the field is hidden.
In any case it is always recommend to use UI policy wherever possible to make the fields hide/read/mandatory on the form. In circumstance where your req doesn't suffice then go with the client scripts.
I hope this clarifies the confusion you have.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2017 02:26 PM
Be aware also that these methods will override UI Policies

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2015 11:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2024 04:41 AM
- setVisible() and setDisplay() are two methods used in ServiceNow for controlling the visibility of fields on a form.
- setVisible(fieldName, isVisible): This method is used to show or hide a field on a form. The 'fieldName' is the name of the field you want to control and 'isVisible' is a boolean value (true or false) that determines whether the field is visible or not.
- Example: g_form.setVisible('short_description', false); This will hide the 'short_description' field on the form.
- setDisplay(fieldName, isDisplay): This method is used to show or hide a field on a form, but it also controls the visibility of the field label. The 'fieldName' is the name of the field you want to control and 'isDisplay' is a boolean value (true or false) that determines whether the field is displayed or not.
- Example: g_form.setDisplay('short_description', false); This will hide the 'short_description' field and its label on the form.
- The main difference between the two methods is that setVisible() only hides the field, but the label for the field remains visible. On the other hand, setDisplay() hides both the field and its label.
nowKB.com