How to set focus on tab

Eli Guttman
Tera Guru

Hi,

i created a custom table with few fields. i decided those fields to 2 tabs.

i was able to hide / show one of the tabs depending on a value in a certain drop down field.

Does anyone know how i can set focus on a tab - so when i change the value of the filed, the tab will open but also get focus?

Thank you

1 ACCEPTED SOLUTION
8 REPLIES 8

Chuck Tomasi
Tera Patron

Hi Eli,



I recommend you try focusing on one of the fields on one of the sections (tabs.) This should help.



Modifying Form Focus - ServiceNow Wiki


Hi Chuck,



can you recommend how to set a focus on a field? for some reason i was not able to do that.



thank you!


Hi Eli,



You would use a client script. However I misspoke, that other link is not a good solution. While it allows you to set the focus on a field, it doesn't work if the current section is not selected.



To set the section focus, see the method setSectionDisplay() here.



Useful Form Scripts - ServiceNow Wiki



This would go inside a Client Script (most likely an onLoad or onChange client script.



Client Scripts - ServiceNow Wiki


Hi Chuck,



yes, i used this function in order to show / hire the section/ tab - however it does not set focus on the section / tab   - it just hide / show it, but the user start on the current open section / tab.