- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2022 10:51 PM
I would like to allow a person holding a specific role to access the following View.
(I want to allow role holders to access other people's ess views.)
・Table : sys_user
・View : ess
・Role : u_itsm_counter
I created the following View Rule Script, but it did not work.
I would appreciate anyone's help.
・Script
(function overrideView(view, is_list) {
answer = view;
if (gs.hasRole('u_itsm_counter')) {
answer = "ess";
}
})(view, is_list);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 09:37 PM
Finally i found the reason.
If a user selected a view manually.
This selection will be the first priority.
Set the test user's view to "default view" and test it !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 09:37 PM
Finally i found the reason.
If a user selected a view manually.
This selection will be the first priority.
Set the test user's view to "default view" and test it !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 09:50 PM
Thank you for your generous support.
From your advice, I have discovered that there is a conflict in the View Rule.
The problem has been resolved. Thank you very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 08:06 PM
Follow OOB View Rule as example for scripting:
/sysrule_view.do?sys_id=77a52fbe0fbf10103ff81b41ff767edd
(function overrideView(view, is_list) {
var isAdmin = gs.hasRole("admin");
var isLocationAgent = gs.hasRole("sn_esm_location_agent");
var isRelationshipAgent = gs.hasRole('sn_customerservice.relationship_agent');
if ((isLocationAgent || isRelationshipAgent) && !isAdmin) //check role here
answer = "case"; //string
else
answer = view; //param
})(view, is_list);
Hope this help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 09:37 PM
Thank you for your reply.
Based on the script you gave us, we tried the following, but unfortunately it did not work.
(function overrideView(view, is_list) {
var isAdmin = gs.hasRole("admin");
var isItsmCounter = gs.hasRole("u_itsm_counter");
if (isItsmCounter && !isAdmin) //check role here
answer = "ess"; //string
else
answer = view; //param
})(view, is_list);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 08:28 PM
Hi, There may be another view rule conflicting with this one. Apart from 'u_itsm_counter' ,user may have other roles assigned to him that is causing redirection to other view.