Business rule to check if person is part of multiple groups ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2023 08:30 AM
Hello,
I need to restrict visibility of Tests within the Test 2.0 module based on the group or groups a person is in..
So my code is below - if they are part of Test Mangement Testers group, they can see tests where product contains EBS.
The problem I have is if they are part of both Test Management Testers and ServiceNow Tester group, they can't see any tests; and they should be able to see both EBS and NOW tests...
Any idea what I'm doing wrong?
if (gs.getUser().isMemberOf('Test Management Testers')) {
current.addEncodedQuery('u_productLIKEEBS');
} else if (gs.getUser().isMemberOf('ServiceNow Tester')) {
current.addEncodedQuery('u_productLIKENOW');
}
else if (gs.getUser().isMemberOf('EnergyGas Tester')) {
current.addEncodedQuery('u_productLIKEENERGYGAS');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2023 08:36 AM
this script will give you the count of groups where logged in user belongs to
update your logic
var groups = new global.ArrayUtil().convertArray(gs.getUser().getMyGroups());
var length = groups.length;
if(length > 1){
// user is member of more than 1 group
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2023 09:10 AM - edited 09-18-2023 09:13 AM
Thank you @Ankur Bawiskar , I appreciate your response! in regard to the new script you just included, do I just add this to the script I currently have? I am not sure where to add this. Thanks agian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 08:26 PM
yes you need to enhance your BR logic by using script I shared
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader