how to write the script in the acl to check the user is admin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-06-2019 05:28 AM
here my requuiremnt is to restrict the users who are having the itil role to not to edit the state fields of catalog tasks on list view when the state is in closed state.
i wants script to put in the acl to check the user role
when the user is admin, this conditions should not work,
if the user is not admin the given conditions should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-06-2019 05:32 AM
Hello,
You can have a write acl on state field and use gs.hasRole("admin") in the script or you can give the role admin under Require roles section;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-06-2019 05:35 AM
The following script will check if the user is Admin and deny/grant access.
if(gs.hasRole('admin')) {
answer = false;
} else {
answer = true;
}
Please mark this as helpful/correct if it resolved your issue!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-06-2019 05:40 AM
Hi there,
How does your write ACL look like now?
I don't think you need a scripted ACL. For example, a write ACL with condition state is not Closed [or just active=true]+ in the Role list just select ITIL. For admins having write access, just check the checkbox admin overrides.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field