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');  
     else  
          g_uri.set('sysparm_view', '');  
}  
  
  
answer =  g_uri.toString('hr_case.do'); 

Use t glide.ui.view_rule.check_after_nav_handler system property to control 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 answerine being outside of the if statement.

To force the Navigation Handler Script above to honoView Rules for the table, add the property above, set it to true, and date 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()) {  
          g_url.set('sysparm_view'),'ess');  
          answer = g_url.toString('hr_case.do');  
     }  
}