how to hide field using javascript
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2016 07:45 PM
how to hide field using javascript
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2016 11:51 PM
You can use below syntax in client script to hide a field.
g_form.setVisible('fieldName', false);
g_form.setDisplay('fieldName', false);
Please go through below link for your reference.
GlideForm (g form) - ServiceNow Wiki
Thanks,
Mihir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 12:22 AM
Hi,
Shiva using
g_form.setVisible('field name',false);
or
g_form.setDisplay('field name',false);
you can hide a field.
Tip:
If you are using it on some record producer variable kindly use g_form.setDisplay('variable name',false); .This syntax on the record producer hides the field and also saves the space of the field,so the next variable can come just in its place.
Please also go through below link for your reference.
GlideForm (g form) - ServiceNow Wiki
Regards,
Shariq.
<Hit like and correct answer if it helps>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 12:24 AM
Hello Shiva,
As for pure Javascript, you can:
document.getElementById("ID_OF_YOUR_ELEMENT").style.display = "none"; -> element is not visible and does not take screen space
or
document.getElementById("ID_OF_YOUR_ELEMENT").style.visibility = "hidden"; -> element is not visible and does take screen space
or use jQuery
$(".divIDClass").hide();
Regards,
Michal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 01:40 AM
Hi,
I would suggest you to do through UI policy
Note:For faster load times, use a UI policy instead of a client script when the only purpose of the script is to set a field to show/hide, read/write, or mandatory/optional.