- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2024 06:22 AM
Hi All,
I am trying to write ACL on glide list type field but it is not working as expected.
Can someone please help me
answer = gs.getUser().isMemberOf(current.field_name);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2024 12:07 AM
Hi @sonu9
you are on the right path by trying to check if the current user is a member of the list stored in that Glide List field, but when you are dealing with Glide List fields, especially those referencing the sys_user table, you will often need to manually parse the list and then check if the current user’s sys_id is one of those in the list. The isMemberOf method won’t directly work in this case because it’s typically used for checking group memberships, not Glide List fields.
//assuming the Glide List field is storing sys_ids from the sys_user table:
var currentUserId = gs.getUserID();
// Get the value of the Glide List field (a comma-separated string of sys_ids)
var glideListValue = "" + current.field_name; // Ensure it’s treated as a string
var userIds = glideListValue.split(",");
// Check if the current user’s sys_id is in the array
var userIsInList = userIds.indexOf(currentUserId) !== -1;
answer = userIsInList;
Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2024 10:31 AM - edited 04-10-2024 10:32 AM
Hi @sonu9 ,
Please check below thread it might be helpful -
https://www.servicenow.com/community/developer-forum/glide-list-acl/m-p/1674205
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.
Thanks,
Astik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2024 10:00 PM
Hi @sonu9
Can you help to share that what is the reference table of the glide list field type? => is it group [sys_user_group]?
And what is your expectation? => is it only group member allow to edit the field?
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2024 11:53 PM
Hi @Tai Vu
It is refering to the user(sys_user table), and my expection is that only selected users are allowed to edit the field.
Please suggest.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2024 12:28 AM
Hi @sonu9
You can check if the current user's sys ID is included in the glide_list field. Sample below.
or
answer = current.getValue('<your_field_name>').indexOf(gs.getUserID()) >= 0;
But I'm still a bit puzzled about your specific needs. What happens if the glide_list field is initially empty? If nobody has filled it in yet, then nobody will be able to edit it, right? So, I'd like to clarify the exact scenario we're trying to address here.
Cheers,
Tai Vu