
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2022 05:07 AM
Hi Guys
I am simply trying to write a code that shows a tab based on a field value.
I chose to use a UI Policy as I thought it may be easier and wrote the following code as the 'Execute if true':
function onCondition() {
g_tabs2Sections.showTabByID('section_tab.sys_id');
g_form.addInfoMessage("Message");
}
The message shows up fine but the tab does not change to show the tab referenced in the code.
For clarity, I want to use showTabByID because I feel its more robust than using tab index as the index can change and is likely to in this form.
Thanks in advance
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2022 05:18 AM
Hey
Have you explored on below:
FUJI UPDATE: In the Fuji release, ServiceNow finally fixes this with a standard g_form call! You can now hide form sections using their name like this…
The first parameter is simply the name of your section, which should be completely lower-case. Sections including spaces should use an underscore in place of the first space with the rest of the spaces removed. For example, a form section with a label of ‘Schedule and Planning’ would require a parameter of ‘schedule_andplanning’. The second parameter is a true/false boolean that indicates whether the form section should be visible or not.
Ref link:
https://servicenowguru.com/scripting/client-scripts-scripting/showhide-form-section/
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2022 05:13 AM
Hi
please have a look on the following great article: https://community.servicenow.com/community?id=community_blog&sys_id=01ccee25dbd0dbc01dcaf3231f9619dc
Kind regards
Maik

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2022 05:36 AM
I saw this article its what made me try to use showTabByID but just not able to get it to work unfortunately

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2022 05:18 AM
Hey
Have you explored on below:
FUJI UPDATE: In the Fuji release, ServiceNow finally fixes this with a standard g_form call! You can now hide form sections using their name like this…
The first parameter is simply the name of your section, which should be completely lower-case. Sections including spaces should use an underscore in place of the first space with the rest of the spaces removed. For example, a form section with a label of ‘Schedule and Planning’ would require a parameter of ‘schedule_andplanning’. The second parameter is a true/false boolean that indicates whether the form section should be visible or not.
Ref link:
https://servicenowguru.com/scripting/client-scripts-scripting/showhide-form-section/
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2022 05:35 AM
On this article the code
'Change Active Tab Selection for Form Sections'
did what I wanted. Id have preferred to use sys_id but beggars can't be choosers lol
Thanks