Hide embedded list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2018 03:51 PM
I have a requirement to hide an embedded list. The article i was referencing to do so seems outdated as I receive an error that $$ is not a valid function. Does anyone know how to hide an embedded list based on a condition? Here is what I originally had before discovering in my debugger that $$ was not valid.
function onLoad() {
//Type appropriate comment here, and begin script below
var list = $$('div[tab_caption="LABEL OF EMBEDDED LIST"]');
var type = g_form.getValue('u_type');
if(list.hasClassName('embedded') && (type == 'sys_id of type field){
list.hide();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2018 08:12 PM
If you put you embedded list into a Form Section, you can hide it using vendor supported API:
GlideForm: setSectionDisplay(String sectionName, Boolean display)
Lets say your Form Section is called 'Embedded List Section'.
Your Client Script would look like this:
function onLoad() {
/* Add yourCondition logic here */
/**/
if (yourCondition == true) {
// Hide the embedded list
g_form.setSectionDisplay("embedded_listsection",false);
}
}
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2018 01:33 PM
thanks Paul, that was helpful but was hoping to find a way specifically for embedded list on a form 🙂 thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2018 03:39 AM
Hello,
I worked on similar issue today and found a solution that seems to be working just fine. This function would hide an embedded list (whatever the form section it's located in). The list_tablename is the table name it's referring to (ex : Affected Cis would be "task_ci").
it's working in London release and meet the strict mode requirements "New client-scripts are run in strict mode, with direct DOM access disabled."
function hide_EmbeddedList(list_tablename){ var sections=g_form.getSections(); // Loop into all form sections for (var i=0;i<sections.length;i++) { // Get elements with class 'embedded' var embedded_elements=sections[i].getElementsByClassName("embedded"); // Loop through those elements and when we get a valid match of the table name of the embedded list we hide it for (var i_element=0;i_element<embedded_elements.length;i_element++) { if (embedded_elements[i_element].getAttribute("tab_list_name_raw")) { if (embedded_elements[i_element].getAttribute("tab_list_name_raw").match("." + list_tablename + ".")) { embedded_elements[i_element].hide(); return; } } } } }

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2018 02:11 PM
Running in to the same error myself, wasn't sure if it was limited to scoped app or if it was happening globally as well. We're on Kingston.