Client Script to get users of a group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 08:44 AM
I have a request to conditionally grant read/write access to users if they are apart of a specific group. Right now I'm trying to figure out how to retrieve this information through client script. I've been going through lots of articles to learn how to write this client script. I have the addInfoMessage to attempt to see what is being retrieved and how it looks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 08:54 AM
What you want to do is create a write ACL on the table as a whole, or the fields in question. To allow access if the current user is a member of a certain group, in the script you can use something like:
if (gs.getUser().isMemberOf("Enterprise Architect Group")) {
answer = true;
} else {
answer = false;}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 09:15 AM
Hi Brad thanks for your response. I have to only allow these users access to a few fields I would need to create an acl for each field right? I was assuming with the client script I can tackle all fields in a single script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 09:52 AM
You can, but securing fields on the client is not the best as there is a brief delay while the form is loading when the field could still be updated, and edits could still be made via list view and potentially other methods.
If you go the client script route, you'll want to pass in the current user as another parameter on the GlideAjax using
g_user.userID
You don't need to pass in the value of a group field unless you're trying to determine if the current user is a member of that group - like a user can update incident fields if they are a member of the assignment_group.
How far did you get in your Client callable getUserGroups Script Include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 10:09 AM
Yes that's exactly what I am trying to do, checking if the member is in one of 3 groups. The script include was already created by another developer. So I am using that to check the user membership, global.getUserGroups.