- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 03-24-2017 06:58 AM
We had an issue where we needed a view dependent on both contents of the task and user and found a solution.
The solution is out there, but I will try to make it simple and findable.
The answer is Navigation Handler, which is found in sys_navigator_list.do
You will also need to be aware of a System Property called: glide.ui.view_rule.check_after_nav_handler
Depending on its setting View Rule or Navigator Handler will be the answer for which a user gets. Set this to "false" to have View Rules be the most important. Often View Rules are set for user groups or task forms, and you may want these adhered to at all times.
Back to Navigation Handler and how to, in our case, allow admins to change views at the same time as other users get a Change form dependent on type. The below code is set in the Navigation Handler and the "sysparm_view" will set the view with corresponding name.
var gr = new GlideRecord('change_request');
//If user isn't admin, set appropriate view
if (!gs.hasRole('admin')) {
if (gr.get(g_uri.get('sys_id'))) {
if (gr.type == 'normal' || gr.type == 'emergency') {
g_uri.set('sysparm_view', 'normal');
answer = g_uri.toString('change_request.do'); }
if (gr.type == 'standard') {
g_uri.set('sysparm_view', 'routineChange');
answer = g_uri.toString('change_request.do'); }
}
}
This was in large parts made possible thanks to Hi and Control how users view data in forms and lists with View Rules and Navigation Handlers
Hopefully my summary and code may give you a short cut to setting up a view choice dependent on both user and task -information.