Script to check is user is in more than 1 group?

SandyL83
Tera Guru

Hello,

I posted a similar question yesterday but really am looking to resolve this 

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? Here is my Business Rule:

 

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

    }

1 REPLY 1

Siyabend Sakik
Tera Contributor

First of all this is an if, followed by an else if statement. That means only the if would be evaluated and afterwards the script would simply end. You either want multiple if conditions or more specific ones checking for both. 

However you said that Users who are in both groups don't see any tests, right? That would mean it doesn't even evaluate the first condition as "true". 

 

I would suggest putting in an "else" case to check if it really skips the first condition or if there is an issue with the encoded Query first.