View rule does not work for setting default view in module
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 04:11 AM
Hello!
I have crawled and trawled through forums and other locations for help on this subject with no success.
I have a module called HR Profiles in a table called sn_hr_core_profiles, in the Human Resource: Core application. For most of the users ever going to use the backend part of the system we want the default view to be a view called NO Default (no_default). Now, I have tried a few scripts with view rules, the latest I have tried is this:
However, when I try to impersonate a user and navigate to that screen I get this:
Showing that the user was NOT directed to NO Default.
I have also tried to go to the Module settings and set the following:
Still, doesn't work.
I know there is something I must do wrong, but I cannot understand what.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 04:58 AM
Hey Makri!
This is very much "unless you know, you've got no chance of knowing" but ServiceNow also has a capability called Navigation Handlers which override view rules. OOB there is one for sn_hr_core_profiles which will be clearing out the view name you're specifying. Navigate to sys_navigator.list and you'll see the navigation handler.
var view = g_request.getParameter('sysparm_view');
var gr = new GlideRecord(hr.TABLE_PROFILE);
if (gr.get(g_uri.get('sys_id'))) {
if (new hr_Profile(gr, gs).canReadProfileFields())
view = '';
else
view = "ess";
}
g_uri.set('sysparm_view', view);
answer = g_uri.toString('sn_hr_core_profile.do');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 05:15 AM
Thanks for your reply. I went to the navigation handler and checked, but it is already implemented by someone else before me. Still doesn't work I am afraid.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 06:25 AM
Potentially I've misunderstood your issue? The following is what I've done to persist a HR profile view based on a module.
- Created a new view and set it on the "HR Profiles" module
- I updated the navigation handler to persist the URI view parameter if the user has view access to the record
From the below, you can see that I switched my list view preference for sn_hr_core_profiles to 'default'. Then when I used the 'HR Profiles' module, the view was correctly persisted to the view record