- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 07:07 AM
Hi,
I'm able to show a User view based on the User role.
How can I add further condition of showing the view based on user role and current field value for that record user opened. (Lets say if status = 'NEW' / 'IN PROGRESS', I want to show a different view for the same user)
Also, What Is the best practice to use views / UI policies? if I meant to display different views at different stages in my workflow to same / different users.
Thanks,
Krishna
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 09:57 PM
Hi,
Please try this out, let me know if it worked.
function onLoad() {
var view =getView().toString(); // Get the current view
if(view == 'itil' || view == 'ess'){
return false; // Dont switch for itil or ess
}else if (// Add your conditions){
switchView('section','incident','my_view');
}
}
Thanks
PS: Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 09:18 AM
Hi,
If I want to try GlideQuery, I still have to get the current record sysid to query from DB.
When you say we can't do both validations at same place, Do you mean that is the system's limitation? That does not sound logical.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 09:37 AM
Yes unfortunately this seems to be a limitation.
The topic was previously discussed in Re: Current object not available in View Rule Script and Nick had checked with HI but they advised that it is not possible. For your scenario you can try to achieve the functionality by an on load client script and using switchView(type, table, view);
The 'type' parameter is either 'list' (to redirect to a list view) or 'section' (to change to a form view).
The 'table' should be your current table
The 'view' should be the view to redirect
On incident form, you can add this in an onLoad client script
function onLoad() {
if(g_user.hasRole('itil') && g_form.getValue('state') == 'new'){
switchView('section','incident','itil');
}
}
Thanks
PS: Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 10:45 AM
Thank you Alikutty.
I tried this one in the morning. However, I see that this is going on infinite loop when I load the form. It's loading again and again.
I believe once it loads the new view, it runs the onLoad() event again and it goes infinite.
Is there a way I can put the condition on this so that if the current view is itil, DO NOT load.
Like - If current view != 'itil' then switchview.
I'm still in learning mode to understand more about the script objects. Very much appreciate your help.
Thanks,
Krishna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 09:57 PM
Hi,
Please try this out, let me know if it worked.
function onLoad() {
var view =getView().toString(); // Get the current view
if(view == 'itil' || view == 'ess'){
return false; // Dont switch for itil or ess
}else if (// Add your conditions){
switchView('section','incident','my_view');
}
}
Thanks
PS: Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2017 07:31 AM
That worked great. Thanks a lot Alikutty.