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 09:51 AM
Maybe you can try field level ACL with script to control this behavior. Script would look something like below.
if (gs.action.getGlideURI().toString().indexOf('<your_table_name>_list') >= 0 && RP.getParameterValue('sysparm_view') == '<your_view>') {
answer = false;
} else {
answer = true;
}
Not sure whether getting URI part will work or not, but the concept is to get the URI and validate the user is on list view and not on form view, and view is your required view.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2022 10:05 AM
Interesting take, If RP is available in ACLs it might work. I don't think you would need the indexOf part since ACLs only run on the table they are setup on. So I don't think there is a need to double check the table name. You would just need the RP.getParameterValue part to verify the view.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2022 10:24 AM
Appreciated!
By using indexOf(), was just trying to ensure that it will only work for list (e.g., incident_list.do) and not form (e.g., incident.do).
In case if RP is not available, then maybe gs.action.getGlideURI().get('sysparm_view') can be utilized.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2022 11:16 AM
Hi Muhammad,
Thanks for getting back. But when I log I receive the value as null.
Somehow gs.action.getGlideURI() does log the URL though.
Regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2022 11:18 AM
Yes but if it is a list ACL it would never run on incident.do it only runs on the list.