- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2025 10:52 PM - edited 07-03-2025 10:58 PM
This read ACL is on sc_req_item table for allowing read access to approvers.
I want to replace using GlideRecord with a different approach as SN doesn't recommend using GlideRecord/GlideRecordSecure/GlideRecordAggregate in ACL
var gr_obj = new GlideRecord('sysapproval_approver');
gr_obj.addQuery('approver', gs.getUserID());
gr_obj.addQuery('sysapproval.parent', current.sys_id);
gr_obj.query();
if (gr_obj.next()) {
return true;
}
return false;
Example 2
This read ACL is on sc_task table to allow read for all fields in sc_task
var task_gr = new GlideRecord('task');
task_gr.addQuery('parent', current.request_item.universal_request);
task_gr.query();
while (task_gr.next()) {
if (gs.getUser().isMemberOf(task_gr.assignment_group.getDisplayValue())) {
answer = true;
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2025 10:56 PM
you can create a script include and function and then write that code there
Then call that script include in ACL advanced script.
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
07-04-2025 01:04 AM
Correct, the script include function will return true/false
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2025 09:04 PM
One quick query - If I move the existing ACL script logic (having the GlideRecord logic to query) to a script include and let the ACL script call this script include, will SN execute the script include logic under ACL context or under script include context ?
The whole point of my requirement is to ensure that the SN health scan report does not flag ACLs that have ACL script using GlideRecord/GlideAggregate as it is not recommended best practice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 01:00 AM
@Ankur Bawiskar , I have marked your answer as Correct and helpful already but 1 quick ask - Is it possible to remove the usage of GlideRecord entirely from above given ACL script examples ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 01:02 AM
you need to create script include function and in that function pass the current object and then handle the logic
that function will return true/false
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
07-07-2025 07:50 AM
@Ankur Bawiskar , I get usage of script include. - Is it possible to remove the usage of GlideRecord entirely from ACL and script include ? I don't want to use gliderecord anywhere. Refer original question 2 examples
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 09:00 AM
for 2nd example you can do like this
answer = gs.getUser().isMemberOf(current.request_item.universal_request.assignment_group);
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