Hiding a list section element in a form via client script or ui policy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2012 01:36 PM
Does anyone know if it's possible to hide a "Section element" via client script or ui policy. Here is the scenario:
I can go into an Incident, Personalize the Form, and choose to add the Knowledge->Source "field". I'd like this to only show up if "Knowledge" is checked and be hidden if it is not checked. The problem is that the field Knowledge->Source does not show up in the UI policie actions lists.
After some further digging, I can see that the Knowledge->Source field is a section element called "12M.incident.kb_knowledge.source" with a type of "list". But I still am unable to make this visible or invisible with any scripting or actions.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2012 02:48 PM
If you're adding it by personalizing the form it's probably an embedded list. You should be able to show/hide that with a client script by following the examples here.
http://www.servicenowguru.com/scripting/client-scripts-scripting/hiding-related-lists-embedded-lists/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2017 06:04 AM
Mark,
I used your exact script and i am getting an error:
onChange script error: TypeError: list.hasClassName is not a function function (){var o=i(m,arguments);return l.apply(n,o)}
var list = ('div[tab_caption="Soil Sample"]')[0];
if(list.hasClassName('list_embedded'))
{
list.hide();
}
We are on Istanbul...Can you check and see what is going on? Did they depricate "hasClassName"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2012 07:42 AM
Hi Mark, thank you for the suggestion. It looks like that should work and if I'm reading it correctly, I should be able to do something like the following:
var list = $$('div[tab_caption="Closure Information"]')[0];
if(list.hasClassName('embedded')){
list.hide()
}
since the list is in the "Closure Information" tab. I do this and get an error:
onChange script error: TypeError: Cannot call method 'hasClassName' of undefined function ...
Any ideas on what I might be doing wrong? This is currently on demo07 on Incident client script "hide knowledge list"

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2012 08:07 AM
Closure information is a form section, not a related list. You'll need to use the examples here for showing and hiding form sections.
http://www.servicenowguru.com/scripting/client-scripts-scripting/showhide-form-section/