Create ACLs based on views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2022 07:57 AM
Hi,
Is it possible to create ACL based on views? I have view on list view where I want to restrict editing a field. But I do not want it to impact other views? Can someone tell how can we we achieve this?
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2022 12:10 PM
Yes, that is correct. If it is list ACL, then there is no need of indexOf(). It should only check for the view via gs.action.getGlideURI().get('sysparm_view') or RP.getParameterValue('sysparm_view').
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2022 06:46 AM
Hi Muhammad
gs.action.getGlideURI().get('sysparm_view') returns null for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2022 09:52 AM
Try this
var answer = true;
if (gs.action.getGlideURI().getMap().get('x_referer').indexOf('sysparm_view=<backend_view_name>') >= 0){
answer = false;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2022 11:40 AM - edited ‎10-14-2022 11:41 AM
It kind of works. However like in my last message if I open incident list from a menu there is no sysparam_view in the url. So therefor the ACL does not work. Example below when going to incident > Assigned to Me
https://<instance_name>.service-now.com/nav_to.do?uri=%2Fincident_list.do%3Fsysparm_userpref_module%3D283b6424c611228501ffeaea1e115220%26sysparm_query%3Dactive%253Dtrue%255Eassigned_to%253Djavascript%253AgetMyAssignments%2528%2529%255EEQ%26active%3Dtrue%5Eassigned_to%3Djavascript:gs.user_id()%26sysparm_clear_stack%3Dtrue

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2022 11:13 AM - edited ‎10-14-2022 11:30 AM
I have noticed a couple things.
- To use gs.action.getGlideURI() you must do it like this otherwise you get null. gs.getProperty("glide.servlet.uri") + gs.action.getGlideURI();
- This does not seems to work in ACLs.
- I tried to do this using a before update business rule. However I found that if you go to the menu Incidents > Open the view is not in the URL unless you refresh the list. So it therefor does not work via a business rule either.
I don't think there is a way to do this without making this impact other views. I'm not sure I understand what your are trying to get out of this. Since the user could just change the view they are on.