Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to Hide Tabs under Sections onLoad?

saint
Tera Expert

Hey Experts,

 

I want to hide tabs under sections and not the section itself for some condition. Please let me know how can I acheive this. I have highlighted what needs to be hidden, let me know if more info is needed.

 

*If I hide the field under computed values when overriden, still that title shows up, and space remains empty, I want to hide the title and field below both!

 

saint_0-1692693641461.png

 

1 ACCEPTED SOLUTION

saint
Tera Expert
10 REPLIES 10

Pratyasha Das
Tera Contributor

You can try the code below:
active=true, reverse if false = true

TRUE CONDITION CODE:


function onCondition() {

g_form.setSectionDisplay('application', false);
/*
//Show the section
var section = $$('span[tab_caption_raw="Application"]')[0].select('span[id*=section.]')[0];
section.show();
//Show the tab
$$('.tab_caption_text').each(function(caption) {
if (caption.innerHTML == 'Application') {
caption.up('.tab_header').show();
}
});
*/
}

 

FOR FALSE code block use:

function onCondition() {

g_form.setSectionDisplay('application', true);

/*
//Hide the section
var section = $$('span[tab_caption_raw="Application"]')[0].select('span[id*=section.]')[0];
section.hide();
//Hide the tab
$$('.tab_caption_text').each(function(caption) {
if (caption.innerHTML == 'Application') {
caption.up('.tab_header').hide();
}
});
*/
}

Pratyasha Das
Tera Contributor

Ensure active=true, reverse if false = true, in UI Policy script to manage conditions

 

For TRUE code block use

 

 

function onCondition() {

g_form.setSectionDisplay('application', false);
/*
//Show the section
var section = $$('span[tab_caption_raw="Application"]')[0].select('span[id*=section.]')[0];
section.show();
//Show the tab
$$('.tab_caption_text').each(function(caption) {
if (caption.innerHTML == 'Application') {
caption.up('.tab_header').show();
}
});
*/
}

 

For FALSE code block use:

 

function onCondition() {

g_form.setSectionDisplay('application', true);

/*
//Hide the section
var section = $$('span[tab_caption_raw="Application"]')[0].select('span[id*=section.]')[0];
section.hide();
//Hide the tab
$$('.tab_caption_text').each(function(caption) {
if (caption.innerHTML == 'Application') {
caption.up('.tab_header').hide();
}
});
*/
}

Sagar Pagar
Tera Patron

Hi @saint,

 

Is "Computed values when overridden" is label or formater? Have you tried by hiding the title?


If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar

The world works with ServiceNow

Hi  @Sagar Pagar  Its an annotation