- 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 08:12 AM
Hi Krishna,
I think it's only based on some condition or role and we could not determine using the form field values
Because when i tried printing the form field value using current.field_name it gave error.
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 08:30 AM
Hi Ankur,
We can do it on condition based without scripting from the same tab,
If I don't click advanced, It gives me a option to choose based on a field value. However, in this case, I'm not seeing the option of selecting View based on User Role.
I need both conditions to be in place for my view.
I'm trying to figure it the code in script to access field values.
Regards,
Krishna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 08:32 AM
Hi,
current is not in the scope of script field and you can do both the validation at a single place. You can either use it as a condition for checking on fields or use script for checking roles etc. The script runs on server side so you can also use Glide queries in it.
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 08:33 AM
Typo.
You can't do both the validation at a single place.
Thanks
PS: Hit like, Helpful or Correct depending on the impact of the response