How to modify the visibility of a related list UI action?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2022 04:50 AM
Dear all,
how/where do I get to modify the visibility of a related list UI action? I did not find it anywhere.
Namely I would like to restrict users to add/remove groups of other users, if they are not the manager of that given group and at the same time they must have the 'itil' or 'itil_admin' role.
I tried to do this through ACLs, but it does not function as expected.
So thought of a workaround of hiding the New/Edit related list UI actions if the signed in user does not fulfill the above mentioned criteria.
I mean these UI actions:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2022 04:57 AM - edited ‎11-25-2022 04:57 AM
Right click on related list column as shown below :
Right click->confgire->List Control
You can check omit new/edit button on form
Please mark answer as Correct or Helpful based on impact.
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2022 05:17 AM
Thank you @Abhijit4 ,
however I need to omit it only for those users, that do NOT have the 'itil' or 'itil_admin' role && are not the manager of the given group that is being added or removed from that user..
My code apparently doesn't work, can you please help me out a bit with it...?
Omit edit and omit new conditions shall be the same:
var answer = false; //restrict access by default
if(gs.hasRoleFromList('itil','itil_admin') && current.group.manager.sys_id == gs.getUserID()) {
answer = true; //allow access if user has 'itil' or 'itil_admin' role and is the group manager
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2022 05:28 AM - edited ‎11-25-2022 05:28 AM
Method 'hasRoleFromList' works for g_user object.
Instead please try below,
var answer = false; //restrict access by default
if((gs.hasRoleExactly('itil') || gs.hasRoleExactly('itil_admin')) && current.group.manager.sys_id == gs.getUserID()) {
answer = true; //allow access if user has 'itil' or 'itil_admin' role and is the group manager
}
if you want to check is user either has role or he is manager then you might need to add OR operator in between as below:
var answer = false; //restrict access by default
if(gs.hasRoleExactly('itil') || gs.hasRoleExactly('itil_admin') || current.group.manager.sys_id == gs.getUserID()) {
answer = true; //allow access if user has 'itil' or 'itil_admin' role and is the group manager
}
Please mark answer as Correct or Helpful based on impact.
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2022 06:52 AM
Hi @Abhijit4
it blocks me out, even if me as an admin cannot see those New/Edit UI actions...
Any suggestions how to do this some other way? Is there any other way than omitting or using ACLs (those did not work in my case)