Hide field (element) by sys_id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2017 08:15 AM
Has anyone tried (and hopefully succeeded) in hiding a form element by sys_id? The standard way to hide a form field is:
setDisplay(fieldName, boolean)
But what if I just wanted to identify the field by sys_id '11e7374a4f37f6041fee7fe24210c737'
I am really trying to hide specific annotation fields and embedded lists...ctomasi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2017 08:42 AM
Hi Neal,
Have you tried using getControl or getElement
http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#getControl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2017 08:42 AM
Once you have the handle of the element, just use XX.style.display= 'none';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2017 09:18 AM
Hi Anurag,
I was looking at both of those but wasn't sure if I could use an onChange client script or possibly UI Policy to perform the "hide/show" of those elements.
Unsure about them because of the following:
getControl(fieldName) requires the field name and "annotation" is the field name which is used all over and isn't unique, so that doesn't help.
I was hoping getElement(id) took the sys_id but it looks like "id" is really the table column label, which again doesn't help me for an annotation field or embedded list.
You mentioned using "XX.style.display= 'none';" but a couple quesitons (assuming we can figure out my earlier questions):
is "XX" the "id" or the var i would return that has the id?
I guess from there I could use a UI Policy with the following:
action if condition True: "XX.style.display= 'none';"
action if condition False: (don't put anything here as the default would be visible. Maybe you could just help with an example?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2017 09:45 AM
Hey Mate,
Just tried this on my personal instance, works like a charm
$j(".annotation-wrapper").hide(); |