How to Avoid GlideRecord in ACL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
I have an ACL on sc_req_item table as below to allow read access to the RITM for sc task approvers.
How to remove GlideRecord usage in ACL and replace with ACL conditions so that it still grants read access to the RITM and variables on it for sc task approvers
var app_obj = new GlideRecord('sysapproval_approver');
app_obj.addQuery('approver', gs.getUserID());
app_obj.addQuery('sysapproval', current.sys_id);
app_obj.query();
if (app_obj.next()) {
return true;
}
return false;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
not possible directly using condition as RITM table doesn't hold approver info
You can move code to Script include and call that in ACL script and you should be good.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago - last edited 2 hours ago
Replace
if (app_obj.next()) {
return true;
}
return false;
by
return app_obj.hasNext();
It's bit more performant as it only checks if there's a record found and doesn't retrieve it, and a bit more performant can matter when running across all your RITMs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
52m ago
I want to completely remove GLideRecord from the ACL and only do with something using
current.request.approvers || current.request.approvers.split(',').indexOf(gs.getUserID()) > -1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
48m ago
Did you check my response which I shared above 1hr ago?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader