ACL on GlideList

sonu9
Tera Contributor

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);

 

 

 

 

1 ACCEPTED SOLUTION

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

View solution in original post

7 REPLIES 7

Astik Thombare
Tera Sage

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

Tai Vu
Kilo Patron
Kilo Patron

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

sonu9
Tera Contributor

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.

 

Hi @sonu9 

You can check if the current user's sys ID is included in the glide_list field. Sample below.

Timi_0-1712820476906.png

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