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

Client Script Action to click on Section tab

chaslage
Kilo Guru

We have a group of fields on a form that are required and in a Section tab, if you click on a "Close" button then it will start the Client Script to check if they have been filled in. If you have the tab open and you add some mandatory fields then it will go right to that field. However, if you are not selected on that tab, it takes you to the tabs but you have to select on the tab that is Red.

I would like to go one further and have that tab automatically open upon click of the "Close" button. Is there a trick with SN to do this or do I have to employ CSS?

Thanks!

14 REPLIES 14

chaslage
Kilo Guru

Answer:
http://www.servicenowguru.com/scripting/client-scripts-scripting/changing-active-tab-selection-servicenowcom/


Mark Stanger
Giga Sage

http://www.servicenowguru.com/scripting/client-scripts-scripting/changing-active-tab-selection-servicenowcom/


chaslage
Kilo Guru

Mark,

Firstly it's an honor to have you reply to one of my posts, my work talks highly about your site and I have had the pleasure of using it as a bible. Secondly, thank you for the link! I am trying to implement it now. Not 100% if this is Berlin friendly or not, I'll let you know.

Chris


chaslage
Kilo Guru

Mark,

Yep, the actual code itself doesn't work...


var tabName = 'Change, Backout, and Test Plan';
var myTabs = $('tabs2_section').select('h3[class="tab_header"]');
var answer = 0;
for (i = 0; i < myTabs.length; i++) {
var inner = myTabs<i>.innerHTML.replace(/ /g, ' ');
if(inner.indexOf(tabName) > -1) {
answer = i;
break;
}
}
//Display the selected section
g_tabs2Sections.setActive(answer);


However, the simple answer using the number works:

g_tabs2Sections.setActive(3);


I assume some changes in Berlin took place. I am too busy to figure out what, but this is fine for now.

Thanks!