Navigation Handler

A Navigation Handler is essentially a scripted View Rule and runs each time data from the specified table is requested in the form view.

The following script, which is a navigation handler included with the HR plugin, forces the ESS view for users with no roles, and uses the default view for all other users.

var gr = new GlideRecord(hr.TABLE_CASE);  
if (gr.get(g_uri.get('sys_id'))) {  
     if (!gs.getUser().hasRoles())   
          g_uri.set('sysparm_view', 'ess');  
          g_uri.set('sysparm_view', '');  
answer =  g_uri.toString(''); 

Use the glide.ui.view_rule.check_after_nav_handler system property to control the order in which View Rules and Navigation Handlers are applied. Set the property value to True to process view rules after navigation handlers. If the system property does not exist in your instance, the navigation handler always takes precedence.

The system property only overrides the Navigation Handler if the Navigation Handler scripted function does not return an answer. In the example script above, the property will have no effect as the Navigation Handler will always return an answer due to the answerline being outside of the if statement.

To force the Navigation Handler Script above to honor View Rules for the table, add the property above, set it to true, and update the code to only return an answer when the view needs to be changed or forced.

var gr = new GlideRecord(hr.TABLE_CASE);  
if (gr.get(g_url.get('sys_id'))) {  
     if (!gs.getUser().hasRoles()) {  
          answer = g_url.toString('');