- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2017 11:13 AM
Hi,
have an form, which has to serve 3 purposes: On, Off-boarding employees and announcing changes (like surname, title, etc.).
The developer of the form is no longer supporting it and I have been asked if I can help.
The form looks like this:
The Form defaults to the user-add version, now to off-board user, or change something about him You need to pick the appropriate tab.
I improved this a bit:
- The form has only HR Info and Devices visible on load
- I added the "Change of User" and "Offboarding" drop down lists (they are both default set to "No")
- After setting one of them to Yes, the appropriate tab appears (used this command: g_form.setSectionDisplay('change_user', false); in UI policy)
Now I would like to change focus (click) the Offboarding tab, when I set the "Offboarding" to Yes (the same for Change user), and hide all other tabs, if possible.
I noticed that You can't hide a tab, when it is focused.
Googled a lot, but this doesn't seem to work for me: g_tabs2Sections.setActive(X);
If I would be developing such a thing I would create 3 separate forms for each task, because now there is a lot of changing/hiding of obligatory fields, which can go wrong in many scenarios
So the most important task for now is to set the focus on the right tab, so people don't get confused.
Our SN is the Geneva version.
Can anyone help, please? I'm fairly new to the developing part of SN (so, please, treat me the noob way).
BR
Jacek
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2017 02:09 PM
Hi Jacek, here is an exmaple of code that is working for us:
try{
var tabIndex = g_tabs2Sections.findTabIndexByName('closure');
g_tabs2Sections.setActive(tabIndex);
}
catch(e){
console.log(e);
//Adding the message with an alert in case g_tabs2Sections changes as it is undocumented
alert(getMessage('message'));
}
As you can see g_tabs2Sections requires an index value, so we retrieve it first using the section name.
Also we used a try catch and set an alert message for our users in case it did not work as this functionnality is undocumented by ServiceNow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2017 02:09 PM
Hi Jacek, here is an exmaple of code that is working for us:
try{
var tabIndex = g_tabs2Sections.findTabIndexByName('closure');
g_tabs2Sections.setActive(tabIndex);
}
catch(e){
console.log(e);
//Adding the message with an alert in case g_tabs2Sections changes as it is undocumented
alert(getMessage('message'));
}
As you can see g_tabs2Sections requires an index value, so we retrieve it first using the section name.
Also we used a try catch and set an alert message for our users in case it did not work as this functionnality is undocumented by ServiceNow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2017 12:41 AM
Woha, this worked without problems, now I'm very surprised.
I did test the g_tabs2Sections using the index value, even testing it by putting the numbers by hand, but this didn't work for me.
I also noticed that the tab name needs to be called using lowercase (I thought that this is case insensitive).
That was an easy one, thank You very much!