- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2020 02:00 PM
I have a field on a form which I want to verify as being hidden/ empty. The field would be hidden if it is empty as that part is already built in. I want to find out if the field is visible or if the field is empty on the form in a client script. Please help. Thanks.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2020 03:28 PM
You could do a check like this.
if (g_form.isVisible('field') || g_form.getValue('field') != '') {
// check if the field is visible or has a value
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2021 03:35 AM
I had an issue that was preventing User's from changing their view because I had a client script checking the length of a field on submit and the field wasn't on the form.
ServiceNow recommended the code below - looks like .hasField() has replaced .isVisible()
It returns true if the field is on the form, and returns empty if its not.
if (!g_form.hasField('short_description')) {
return true;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2021 05:14 AM
You could check with that:
if(g_form.isVisible(g_form.getGlideUIElement("your field")== true){
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2021 05:27 AM
hi,
It will return true if the field is visible.
g_form. isVisible("fieldName");