
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 01:39 PM
I just created a simple onLoad script to check and set a form view on an Incident.
// Simple onLoad script
function onLoad() {
var view = getView().toString();
if(view == '') {
switchView('section','incident','mobile');
}
return;
}
My issue is that I didn't find any documentation for this. Does this mean that this is an un-supported, un-documented way to check and set form views?
And that it may go away at any time with future version updates?
If this is un-documented and volatile, what's the proper way, when using an onLoad script on the client side, to get and set a form view?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 01:46 PM
Checkout View Rules, Eric.
https://docs.servicenow.com/bundle/madrid-platform-user-interface/page/administer/navigation-and-ui/task/t_CreateAViewRule.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 01:46 PM
Checkout View Rules, Eric.
https://docs.servicenow.com/bundle/madrid-platform-user-interface/page/administer/navigation-and-ui/task/t_CreateAViewRule.html

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 02:38 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2020 02:55 PM
Good Afternoon
Thank you all in advance for your help.
I have tried to create the View Rule 2 different ways.
1) Using the Advanced view, i.e. a script
(function overrideView(view, is_list) {
var currentUser = gs.getUser();
var userGroupGP_CSP = currentUser.isMemberOf('GP CSP');
if (userGroupGP_CSP) {
answer = 'CSP Team'; // set the new view to answer;
}
})(view, is_list);
The script runs and the userGroupGP_CSP variable is set correctly (I walked through it in the debugger) but the view is not set.
So I tried a second method.
2)
Please note: We are in a Domain Separated environment so in both cases the View Rule was created in the Top Domain of this client.
Neither method works. What am I missing?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2020 01:44 PM
After I found out about them, I love view rules. I've also found that if I have a view with a space in the name, I had to add an underscore to get it to work.
I was using Madrid at the time, but I've carried that over whenever I create a new view rule and it seems to be needed.
So on the view rule entry, instead of view [ CSP Team ]
Make it view [ CSP_Team ] and give that a try.
I don't know if that's documented anywhere, but it works on my instances.