check if logged in user is part oof anyone of the given groups
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2023 11:39 PM
In a system property sys_xyz, we will have certain groups. In script include i need to check if user is part of anyone of the groups mentioned in that system property. Please suggest best practise on how to do this .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2023 11:56 PM
Hello @RC19
For an example there is a system property :- glide-grp-name
var index = 'Group';
var props = gs.getProperty('glide-group-name');
var hashMap = JSON.parse(props); // Add global prefix if in scope
var answer = hashMap[index]; // answer will store the sysid of group.
gs.getUser().isMemberOf(answer);
Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2023 11:59 PM
Hi @Samaksh Wani,
Thanks for your reply. but actually my main concern is that my system property contains multiple groups . But isMemberOf() only works for single group i think . please suggest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2023 12:09 AM
Hello @RC19
For Multiple Group you can use 2 approach :-
1. gs.getUser().isMemberOf(group1) || gs.getUser().isMemberOf(group2) || gs.getUser().isMemberOf(group3);
2.
var groupsArray = ['CAB Approval', 'Change Management', 'xyz'];
for(var y=0; y < groupsArray.length; y++){
var isMember = gs.getUser().getUserByID('abc').isMemberOf(groupsArray[y]);
}
Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.
Regards,
Samaksh