The CreatorCon Call for Content is officially open! Get started here.

Hide Tab/Section in client script

Mohamed Faizel
Giga Expert

Hi,

How to hide the form sections and tab using client script?

I   was trying the below client script with the reference of http://www.servicenowguru.com/scripting/client-scripts-scripting/showhide-form-section/

It was not working, hope it was working fine in Eureka   and we are in fuji now and it's not working in fuji, i tested in demo also, the below script not working

function onLoad() {

  //Hide the section

var section = $$('span[tab_caption_raw="Questions"]')[0].select('span[id*=section.]')[0];

section.hide();

  alert(section);

//Hide the tab

$$('.tab_caption_text').each(function(caption) {

      if(caption.innerHTML == 'Questions'){

              caption.up('.tab_header').hide();

      }

});

}

Could any one please help on this?

Thanks.

1 ACCEPTED SOLUTION

Mohamed Faizel
Giga Expert

I just tried the below script in Fuji, i can hide the section.


function onLoad() {  


var sections = g_form.getSections();  


sections[4].style.display = 'none';


}


Thanks.


View solution in original post

17 REPLIES 17

This is a more appropriate answer to me since it uses ServiceNow's client-side API


sumana1707
Mega Contributor

Hi Mohamed,



Can you also let me know, how to make the all the fields of a particular section read only ?



Regards,


Sumana


Ratul Arora
Kilo Guru

hi, I have tried this and its working well.

 

var value = g_form.getValue('u_problem_status');

if(value == 3)
{
g_form.setSectionDisplay('problem_investigationteam',true);  // here  my section name was like "Problem Investigation Team" so for                                                                                                         firstspace use "_" rest no space and all chracters in smallcase.
}
else
{
g_form.setSectionDisplay('problem_investigationteam',false);
}