Hiding a list section element in a form via client script or ui policy

mdenis
Kilo Contributor

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.

5 REPLIES 5

Mark Stanger
Giga Sage

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,



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"


mdenis
Kilo Contributor

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"


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/