ACL with GlideRecord
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2024 08:47 PM
answer = false;
var assignmentGroups;
var groupArray = [];
if (current) {
assignmentGroups = current.getValue('related_assignment_groups').toString();// a list field which holds all the related assignment groups worked on that ticket
groupArray = assignmentGroups.split(',');
//To check if the current user is a manager of any of the related groups if yes, then show the record
var groupGR = new GlideRecord('sys_user_group');
groupGR.addQuery('manager', gs.getUserID());
groupGR.addQuery('sys_id', 'IN', groupArray);
groupGR.query();
if (groupGR.next()) {
answer = true;
} else {
//to check if the user is a member of any of the related groups list.
answer = groupArray.some(function(group) {
return gs.getUser().isMemberOf(group.trim());
});
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 02:43 PM
Thanks @Maik Skoddow that makes sense!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2024 09:32 PM
@JohnnySnow You can replace the GlideRecord query by creating Dynamic filters. Please refer to the dynamic filter for One of My Assignment groups and replicate the same logic for related_assignment_group. Similarly, for the manager you can create another dynamic filter which will check Related Assignment Group. Manager is (dynamic) Me.
This will eliminate the need of using repetitive GlideRecord calls in ACL for more information on dynamic filters please refer to https://docs.servicenow.com/bundle/vancouver-platform-user-interface/page/use/using-lists/task/t_Dyn....
Hope this helps.