{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":42067,"path":"platform-user-interface/c_NavigationHandler.md","title":"Navigation handler","bundle":null,"doc_type":null,"release":"australia","body":"\n# Navigation handler\n\nA navigation handler is a scripted view rule and runs each time data from the specified table is requested in the form view.\n\n## Create a navigation handler\n\nThe Navigation Handler \\[sys\\_navigator\\] table contains the navigation handlers on your instance. Access this table by entering `sys_navigator.list` in the filter navigator. Navigation handler records contain a **Table** field to specify which table the navigation handler applies to, and a **Script** field containing the scripted view rule.\n\nThe following script comes from navigation handler included with the HR plugin. The script forces records from the table in the **Table** field to use ESS view for users with no roles, and default view for all other users.\n\n```\nvar now_GR = new GlideRecord(hr.TABLE_CASE);  \nif (gr.get(g_uri.get('sys_id'))) {  \n     if (!gs.getUser().hasRoles())   \n          g_uri.set('sysparm_view', 'ess');  \n     else  \n          g_uri.set('sysparm_view', '');  \n}  \n  \n  \nanswer =  g_uri.toString('hr_case.do'); \n```\n\n## Run navigation handlers before or after view rules\n\nUse 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.\n\nThe 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 has no effect. This is because this navigation handler always returns an answer due to the `answer` line being outside of the `if` statement.\n\nTo force the navigation handler script in the preceding example to honor view rules, take the following steps:\n\n1.  Create the **glide.ui.view\\_rule.check\\_after\\_nav\\_handler** system property.\n2.  Set the value of the property to `true`.\n3.  Update the navigation handler script to only return an `answer` when the view must be changed or forced.\n\nThis example is a modified version of the previous script. In this case, the `answer` line only occurs when the user has no roles. If the user has roles, `answer` is never reached, and view rules on the same table, if any, are applied.\n\n```\nvar now_GR = new GlideRecord(hr.TABLE_CASE);  \nif (gr.get(g_url.get('sys_id'))) {  \n     if (!gs.getUser().hasRoles()) {  \n          g_url.set('sysparm_view'),'ess');  \n          answer = g_url.toString('hr_case.do');  \n     }  \n} \n```\n\n**Parent Topic:**[View management](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-user-interface/view-management-overview.md)\n\n"}}